Resize to 800x600 or 600x800 (conditional resize)

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
ridera

Post by ridera »

I solved this problem by simply measuring the X and Y ratio and resizing as required.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

If you know the image has a 4:3 or a 3:4 aspect ratio... then just resize the image to the larger size and the other will be automatically handled.

EG: -resize 800x800
will do what you asked. It will fit the image into that sized box and adjust the dimensions to preserve the aspect ratio.

If you have no control of your images aspect ratio, then you will need to define exactly what you want done EG if you are given a 1024x20 image (a section seperator 'line' for a web page, what do you want as a result.

Basically the solution depends on how much control you have on the input images.
For more see IM Examples Resize
http://www.cit.gu.edu.au/~anthony/graph ... k6/resize/
and more specific (and smaller scale) examples
http://www.cit.gu.edu.au/~anthony/graph ... humbnails/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Post by anthony »

You are most welcome.

Often the default action of IM is just what you need, if you just allow it to do its job ;-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply