crop empty space around images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply

crop empty space around images

Post by tester » 2010-02-27T13:00:32-07:00


Is there a way to -crop "automatically" the white border or empty space around the images like e.g. with gimp?
Please let me know how to solve this because I miss the option at the crop manual page :-/

Thanks a lot

Posts: 2835
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: crop empty space around images

Post by Bonzo » 2010-02-27T13:59:49-07:00

User avatar
Posts: 21873
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: crop empty space around images

Post by fmw42 » 2010-02-27T14:19:33-07:00

also see -fuzz to allow your trim to be less sensitive to slight color variations in the area you want to trim.

see ... s.php#fuzz

for example,

convert image -fuzz 1% -trim +repage result

The +repage removes the virtual canvas which is the size of the input and makes the output just the trimmed size.


Posts: 11
Joined: 2015-05-04T21:05:35-07:00
Authentication code: 6789

Re: crop empty space around images

Post by jauson » 2016-12-07T19:44:49-07:00

I had an issue with a png having a slight bit of transparency, which resulted in removing the transparency part, and leaving the white areas. To fix it, first I had to flatten, then trim.

Code: Select all

convert partial-trans.png -flatten -fuzz 1% -trim +repage trimmed.jpg

Post Reply