Page 1 of 1

How can I -trim an image more aggressively?

Posted: 2016-02-23T14:27:15-07:00
by bobhwantstoknow
Hello,

I have this image
Image
I can use the -trim option to produce this result
Image
I would like to achieve a more aggressive trim to produce a result like this
Image
Remove all of the border color while leaving the maximum possible remaining pixels. Is there a way to do that? I realize that there would be many cases that would produce a 0x0 image, but that won't be an issue in my case.

Debian Linux
Version: ImageMagick 6.8.9-9 Q16 i586 2015-01-05

Thanks

Re: How can I -trim an image more aggressively?

Posted: 2016-02-23T15:19:30-07:00
by snibgo

Re: How can I -trim an image more aggressively?

Posted: 2016-02-23T15:26:35-07:00
by fmw42
Why not just make the white into transparent? Or the white and black to transparent, leaving just the green, then trim to get the bounds of the green. Or make the white into black and trim.

Try this (unix syntax)

Code: Select all

convert t0NeV0C.png -fuzz 20% -fill black -opaque white -trim +repage result.png

Re: How can I -trim an image more aggressively?

Posted: 2016-02-23T22:05:04-07:00
by bobhwantstoknow
snibgo wrote:Fred has a bash script: http://www.fmwconcepts.com/imagemagick/ ... /index.php

This works great. Thanks.