Page 1 of 1

How to resize image more intelligently?

Posted: 2007-06-05T20:19:51-07:00
by lakershen
I am new to ImageMagick. Try to resize image for my web users on the fly. Here's what I want:

if the shape of image is width > length, resize it and make the width as 50.
if the shape of image is length > width, resize it and make the length as 50.

I understand ImageMagick convert commant can take either width or length and set the other value proportionally. However, seems there's no way to do this kind of smart resize directly.

How to solve the problem?

thanks!

Re: How to resize image more intelligently?

Posted: 2007-06-06T18:50:03-07:00
by anthony
Which IM has some IF constructs in say a -rotate command, That is if landscape make it protrait before doing the resize, It can't tell later if it should rotate the image back again! Not unless some exif attribute is updated by the normal rotate.

Basically you are asking to much of the command line operation sequence, whcih has no IF-ELSE construct.

You will need to identify the image first and then pick the right convert command,
or use an API like PerlMagick that can make desicions in the middle of a operation sequence.

Re: How to resize image more intelligently?

Posted: 2007-06-06T23:36:08-07:00
by lakershen
Thanks. Fair enough.

Not sure how exactly imagemagick works. It should not be too hard to add this smart convert command to resize the image. I think a lot of users should have similar request. Unfortunately, I am using java to build my website. Maybe I have to use the java native image library, although it requires a lot of memory.

Re: How to resize image more intelligently?

Posted: 2007-06-07T05:23:18-07:00
by glennrp
convert -resize 50x50
should do exactly what you want.

Re: How to resize image more intelligently?

Posted: 2007-06-07T16:40:54-07:00
by anthony
Oh yes of course. you are resizing the LONGEST length, do just resize it to a box 50x50.

Sorry, I was in a frame of mind from another request that had two complely different sizes depending on the whether the image is landscape or portrait, which is a definate IF-ELSE construct. That is not the case here. Appoliges.