2010. október 27.

Working in Imagemagick

Clearing margin area

I'm working on a scanned text page, that needs a cleanup on the margins.
the original image size is 2736x3928 and it's a pbm file.
~$ convert orig.pbm -crop 2320x3928+120+0 crop.pbm
this cuts down 120 pixels from the left side, and 2736-120-2320=296 pixels from the right side.
~$ convert crop.pbm -bordercolor white -border 296x0 -gravity none -crop 2736x3928+176+0 back.pbm
this puts back the cut-down border in the color white. (first we add a 296 pixel wide border to both sides, which makes our image 296+296+2320=2912 wide. we only need the 296 border on the right side, so we crop the one on the left to be 120 px with 296-120=176 pixels. check: 2912-176=2736 we counted right.)

You have to do this 2 step separately. You can use mogrify instead of convert to edit multiple files, but ALWAYS make a backup copy of your files before using mogrify!

That's it. Enjoy.

Nincsenek megjegyzések: