7

I am resizing images using ImageMagick. If I pass a -resize WxH option it behaves as expected. But if I pass -resize WxH! (to ignore aspect ratio during resize), some images, especially PNGs, are actually increasing in size. A 200k image becomes 450k, a 170k image becomes 360k and so on.

Any ideas why this is hapenning and how to fix it?

Thanks

Faisal
  • 19,358
  • 4
  • 30
  • 33
  • Can you provide an example (including mage file and target dimension)? – Joachim Sauer Sep 29 '09 at 11:50
  • Maybe it's killing the compression of the png, tried setting it with a switch? – Bobby Sep 29 '09 at 12:03
  • @Bobby: I dont exactly understand what you're saying. What switch? @Joachim: Target size is 950x140. Sample image at http://s3.amazonaws.com/devshots.ikbis.com/channels/21/headers/2009-02-8_original.jpg – Faisal Sep 29 '09 at 12:46
  • The example image you link to is a JPG image, that means it uses lossy compression. If you convert it to a PNG file (which is a lossless format), then the resulting file will almost certainly be bigger unless you resize it to a *significantly* smaller width/height at the same time. – Joachim Sauer Sep 29 '09 at 14:38
  • @Joachim: Thank you for your clarification. Here is another example of a PNG image that was resized to 950x140 ignoring aspect ratio, and file size more than doubled (150k => 370k). Original: http://bit.ly/HKcd2, resize: http://bit.ly/8070i Any input would be appreciated – Faisal Sep 30 '09 at 06:56
  • same issue appears with 6.8.9 version – Nithin Dec 30 '16 at 10:29

1 Answers1

8

After researching, I upgraded my ImageMagick version from 6.3.7 to 6.5.6, and now it is working great. Resizing images is generating smaller images and everything is OK.

Faisal
  • 19,358
  • 4
  • 30
  • 33
  • 1
    Just upgrading did the trick? I'm running ImageMagick 6.5.7 and I get the same odd behavior you mentioned, see http://stackoverflow.com/questions/5818603/issues-porting-php-gd-wrapper-to-imagick. – Alix Axel May 07 '11 at 04:10