Page 1 of 1

Edge cleaning?

Posted: 31 Aug 2019, 10:15
by steve54301
I have been seeking something (Linux command line batch style) that cleans the edges of .jpg scans. Something that just replaces a few millimeters on the left and right with white.

I am sure this can be done with imagemagick somehow, I just haven't figured it out yet.

Re: Edge cleaning?

Posted: 31 Aug 2019, 14:59
by cday
steve54301 wrote: 31 Aug 2019, 10:15 I have been seeking something (Linux command line batch style) that cleans the edges of .jpg scans. Something that just replaces a few millimeters on the left and right with white.

I am sure this can be done with imagemagick somehow, I just haven't figured it out yet.
The imagemagick forum is probably a good place to seek help on that, I remember a while back someone with a different need received excellent support...

The XnView command line utility NConvert is another possibility, providing crop and canvas resize operations for example, but I have only developed Windows scripts, although the basic code should be the same; if you develop a Linux script I would be interested to see it!

Edit:

Unless you particularly want a command line solution, it should be easy to do what you want directly today using the excellent cross-platform XnConvert GUI batch conversion software. Without testing it, I think that two canvas resize actions will do what you need:

1 A canvas resize to, for example 98% image width about the center, to clean the edges;

2 A canvas resize to 102% image width about the center, with the background colour for the canvas added set to white, to restore the original width.

Re: Edge cleaning?

Posted: 23 Sep 2019, 16:51
by dtic
steve54301 wrote: 31 Aug 2019, 10:15 I have been seeking something (Linux command line batch style) that cleans the edges of .jpg scans. Something that just replaces a few millimeters on the left and right with white.
Not a Linux utility but BookCrop https://github.com/nod5/BookCrop has a scrub mode where you draw a rectangle over the overlay of all images in a batch to make that area white in all images in the batch. It uses GraphicsMagick (similar to ImageMagick) under the hood.

Here's an example of the type of command line syntax you'd use.

Code: Select all

gm.exe convert "C:\dir\image.tif" -fill white -draw "rectangle <X0>,<Y0> <X1>,<Y2>" "C:\dir\image_output.tif"
Both GraphicsMagick and ImageMagick have pretty good manuals so you can probably easily find ways to modify the command to do exactly what you want.

References
http://www.graphicsmagick.org/convert.html
http://www.graphicsmagick.org/GraphicsM ... tails-draw