Page 1 of 1
Removing Black Borders from Image
Posted: 2011-08-05T06:51:38-07:00
by sameersbn
Hi,
I have developed application that uses ffmpeg to generate a thumbnail of a video. If the video has black borders then the black borders are also part of the image. I was wondering if it was possible to clip the black borders from the image using magick. Tried searching on google but could not find anything useful (still looking).
Here is a sample image with black borders
Thanks and Regards
~Sameer
Re: Removing Black Borders from Image
Posted: 2011-08-05T07:33:18-07:00
by Bonzo
Re: Removing Black Borders from Image
Posted: 2011-08-06T12:38:24-07:00
by sameersbn
great! thanks for the info.
i was trying to figure out how -fuzz is specified. the doc says distance but couldn't figure out how it is specified.
Re: Removing Black Borders from Image
Posted: 2011-08-06T12:59:53-07:00
by Bonzo
I think fuzz is a percent so it would be something like this:
Code: Select all
convert image_in -fuzz 20% -trim image_out
Re: Removing Black Borders from Image
Posted: 2011-08-06T13:06:39-07:00
by fmw42
Bonzo wrote:I think fuzz is a percent so it would be something like this:
Code: Select all
convert image_in -fuzz 20% -trim image_out
Don't forget the +repage after the -trim if the output is png or gif or tif and not jpg
see
http://www.imagemagick.org/Usage/crop/#trim
P.S. Fuzz values can be absolute graylevel in the range of your compile Q8 (0-255) or Q16 (0-65535), but I find percents easier and more flexible and transportable
Re: Removing Black Borders from Image
Posted: 2011-08-06T22:30:37-07:00
by sameersbn
This is perfect.
Thanks guys.
Re: Removing Black Borders from Image
Posted: 2011-08-07T01:12:18-07:00
by sameersbn
For reference here's the command i am using:
Command:
convert before.jpg -bordercolor black -border 1x1 -fuzz 20% -trim after.jpg
References:
http://www.imagemagick.org/script/comma ... s.php#trim
http://www.imagemagick.org/Usage/crop/#trim
Regards
~Sameer