Page 1 of 1

How can I resize to fixed dimensions?

Posted: 2013-05-07T18:11:05-07:00
by adamsilver
Hello,

I searched a lot and I couldn't figure out how to achieve the following:

I have a news aggregation service so I am getting images of various dimensions. I have to create a 3 versions of the aggregated story image:

50x50, 150x100 and 278x209.

The dimensions must be absolutely what's mentioned above.

I currently have this:

Code: Select all

convert {input} -resize {dimensions} {output}
But sometimes my specified dimensions are not being strictly adhere to, I don't know why.

I don't want to end up with deformed images either if I prevent images from scaling proportionally.

What are my options?

Your help would be appreciated.

Re: How can I resize to fixed dimensions?

Posted: 2013-05-07T19:00:51-07:00
by GreenKoopa
If, for example, you want to create a 50x50 image from a 100x124 image, you can:
  • resize it to 40x50 (what you are probably doing now)
  • resize it to 40x50, then add margins (of any color, maybe even transparency) to 50x50
  • resize it to 50x62, then crop it to 50x50
  • squish it into 50x50, causing some distortion
Which option would you like?

Re: How can I resize to fixed dimensions?

Posted: 2013-05-07T19:44:56-07:00
by fmw42

Re: How can I resize to fixed dimensions?

Posted: 2013-05-07T22:40:14-07:00
by anthony
Also see Resize Flag 'no aspect'
http://www.imagemagick.org/Usage/resize/#noaspect

The other resize flags in that same area may also be useful..

But you need to be clear about exactly what you are wanting for us to help you further.