Page 1 of 1

resize geometry

Posted: 2010-03-11T14:46:50-07:00
by bpalme
Hi,
I'm trying to use these two geometry parameters:
width Width given, height automagically selected to preserve aspect ratio.
xheight Height given, width automagically selected to preserve aspect ratio.
But when I try both of them, I get the same results. Here is some sample output:

Code: Select all

bpalme@dakar:~/projects/wikipedia$ identify 400x640.png
400x640.png PNG 400x640+0+0 DirectClass 8-bit 5.8K 0.000u 0:01
bpalme@dakar:~/projects/wikipedia$ convert 400x640.png -resize 'x300' x300.png
bpalme@dakar:~/projects/wikipedia$ convert 400x640.png -resize '300' 300.png
bpalme@dakar:~/projects/wikipedia$ identify x300.png
x300.png PNG 188x300+0+0 DirectClass 8-bit 5.0K 0.000u 0:01
bpalme@dakar:~/projects/wikipedia$ identify 300.png
300.png PNG 188x300+0+0 DirectClass 8-bit 5.0K 0.000u 0:01
I expected the dimensions of the 300.png image to be 300x480. Am I doing something wrong? Am I misinterpreting the documentation quoted above?

Thanks for any insight on this!
Brent

Re: resize geometry

Posted: 2010-03-11T15:18:24-07:00
by fmw42
It works for me on IM 6.6.0-4 Q16 Mac OSX Tiger

# create 400x640 image from IM internal image logo:
convert logo: -rotate 90 -crop 400x640+0+0 +repage logo_r90.png
identify logo_r90.png
logo_r90.png PNG 400x640 400x640+0+0 8-bit DirectClass 85.3KB 0.020u 0:00.019

# resize height to 300
convert logo_r90.png -resize x300 logo_r90_x300.png
identify logo_r90_x300.png
logo_r90_x300.png PNG 188x300 188x300+0+0 8-bit DirectClass 32.4KB 0.000u 0:00.010

# resize width to 300
convert logo_r90.png -resize 300x logo_r90_300x.png
identify logo_r90_300x.png
logo_r90_300x.png PNG 300x480 300x480+0+0 8-bit DirectClass 69.5KB 0.010u 0:00.019

# resize width to 300
convert logo_r90.png -resize 300 logo_r90_300.png
identify logo_r90_300.png
logo_r90_300.png PNG 300x480 300x480+0+0 8-bit DirectClass 69.5KB 0.010u 0:00.020

What version of IM are you using? Perhaps you need to upgrade!

convert -version

Note also:

-resize 300x300 will resize the largest dimension of the image to 300 and scale the smaller to preserve aspect ratio of the input

-resize "300x300^" will resize the smallest dimension of the image to 300 and scale the larger to preserve aspect ratio of the input

Re: resize geometry

Posted: 2010-03-12T07:26:06-07:00
by bpalme
Thanks for the quick reply and sanity check. It turns out that there was *ahem* a different implementation installed on this machine. Once I switched it out for ImageMagick, it works fine.

Brent