Edge cleaning?

Discussions, questions, comments, ideas, and your projects having to do with DIY Book Scanner software. This includes the Stereo Data Maker software for the cameras, post-processing software, utilities, OCR packages, and so on.

Moderator: peterZ

Post Reply
steve54301
Posts: 1
Joined: 29 Aug 2019, 18:38
Country: USA

Edge cleaning?

Post 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.
cday
Posts: 451
Joined: 19 Mar 2013, 14:55
Number of books owned: 0
Country: UK

Re: Edge cleaning?

Post 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.
dtic
Posts: 464
Joined: 06 Mar 2010, 18:03

Re: Edge cleaning?

Post 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
Post Reply