Page 1 of 1

Trim with limitations

Posted: 2014-01-30T12:13:52-07:00
by novito
Hi guys,

I am using the trim function in order to get rid of a background surrounding a product image. However, the trimming sometimes cut too much, and I would like to know if there is a way of giving trim the option to say, give 2px of margin from wherever you were gonna cut to.

I haven't been able to found that on the docs, so I thought you guys could have any ideas.

Thanks

Re: Trim with limitations

Posted: 2014-01-30T12:17:46-07:00
by fmw42
You can get the trim bounds by

identify -format "%@" yourimage

put that into a variable or separate into the needed variables. Then add whatever extra you want. Then use -crop WxH+X+Y +repage to crop it with your modified trim variables for W,H,X,Y.

see
http://www.imagemagick.org/script/escape.php