Orientation dependent resizing

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
mschipperheyn

Orientation dependent resizing

Post by mschipperheyn »

Hi,
I would like to be able to use orientation dependent resizing. Since I don't know the widht x height of the image I'm feeding to ImageMagick, I would like ImageMagick to figure out the orientation and resize proportionally based on a max width of X in landscape and max height of Y in portrait.

Does anyone know how to do this?

Kind regards,

Marc
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Orientation dependent resizing

Post by Bonzo »

Check out: http://www.imagemagick.org/script/comma ... php#resize
and : http://www.imagemagick.org/script/comma ... p#geometry

I think you want the standard -resize widthxheight without any options.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Orientation dependent resizing

Post by anthony »

Basically the default operation is to resize an image so it fits into the bound given as the resize argument, while preserving the images aspect ratio. Generally it means only one of the dimensions of the resulting image will match the dimension given.

Their are options (flags) that will make turn of aspect preservation, and force the image to become the size given exactly

or to make the image size so it the given dimensions just fits inside the result (minimal dimentions made to fit rather than maximum dimension.

See IM Examples Resize
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Orientation dependent resizing

Post by fmw42 »

-resize XxY will always look for the largest size and scale that to eithr XxY depending on whether width or height is larger and keep the aspect ratio. If you want to resize by the smaller dimension, then use the ^ flag. see all the resize options at http://www.imagemagick.org/script/comma ... p#geometry and examples at http://www.imagemagick.org/Usage/resize/#resize

see also my scripts aspect and aspectpad at the links below
Post Reply