Page 1 of 1

How to crop immage to first non white pixel from edges

Posted: 2016-12-29T03:13:07-07:00
by hogo
Using slow satellite connection and need to crop white space around scanned image. Image is not always in right position (can be rotated a bit) and size is different.
I need to find first non white pixel from the edge from all 4 sides. Then crop image.

Is there direct function for it or I need to play around.

Thank you for help.

Re: How to crop immage to first non white pixel from edges

Posted: 2016-12-29T03:23:43-07:00
by snibgo
There is no direct function for this. I show a method on my "Inner trim" page, including a Windows BAT script.

Re: How to crop immage to first non white pixel from edges

Posted: 2016-12-29T10:52:22-07:00
by fmw42
Are you trying to remove the outer white area? If so, then try -trim. See http://www.imagemagick.org/Usage/crop/#trim

You can also unrotate the image using -deskew (before trimming), if the rotation is less than about 5 deg. See http://www.imagemagick.org/script/comma ... php#deskew. If on a Unix-type platform, you can try my script, unrotate at my link below.

Please always provide your IM version and platform, since syntax may differ. An example image always helps, too.