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?".
bpalme
Post
by bpalme » 2010-03-11T14:46:50-07:00
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
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2010-03-11T15:18:24-07:00
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 300 x480 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 300 x480 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
bpalme
Post
by bpalme » 2010-03-12T07:26:06-07:00
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 Image Magick, it works fine.
Brent