[magick-users] resize based on the longer dimension

Scott scotbicknel at cox.net
Sun Nov 18 19:27:56 PST 2007


On Sunday 18 November 2007 6:30:30 pm Steven Woody wrote:
> hi,
>
> i want to resize batch of pictures to a smaller size.  the
> rule is every picture's longer edge should be reduce to 800
> pixels, and the another edge keep the aspect ratio.  how can i
> do this using `convert' command?  i found the problem is how
> to get know what ( W or H ) is the image's longer edge.

Assuming you are using a shell like bash:

You can use: 
width=$(identify -format '%w' filename) to get the width and
height=$(identify -format '%h' filename) to get the height

You can use an if test to figure out which side to scale and
scale the image with:
convert -scale x800 filename to scale on the vertical side and
convert -scale 800 filename to scale on the horizontal side
-- 
Scott
Linux user #: 246504


More information about the Magick-users mailing list