trim, then scale, distorting aspect ratio

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?".

trim, then scale, distorting aspect ratio

Post by zikko »


I want to do two simple operations on images. Trimming and resizing.

Using -trim and -resize separately works fine. The problem occurs when I use both. When the amount of white space trimmed off the image is not the same on the four sides, the following resize distorts the aspect ratio of the image.

My spontanious guess is that the rescaling is based on the original aspect ratio of the image rather than on the aspect ratio of the trimmed image.

The following two does not output identical images:

convert "logo.jpg" -trim z.jpg
convert "logo.jpg" -trim -resize 100% z.jpg

There's probably some option or something I can stick in there to fix this, right? :)

User avatar
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Add +repage after -trim to get the expected results.