Page 1 of 1

ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-21T15:12:42-07:00
by curlyman72
0 vote down star


using the latest version of imageMagick for windows (downloaded today)
small_image.jpg = 16x16
large_image.jpg = 800x600

convert small_image.jpg -gravity Center -resize '208x120>' -background white -extent 208x120 s_icon.gif

produces: "convert: invalid geometry `'208x120' @ geometry.c/ParseRegionGeometry/1322" yet it still produces a 208x120 image with the tiny 16x16 image perfectly centered within the new image and canvas size. Perfect.

However, if I try it with the larger image, it gives me the same error but it actually seems to crop rather than scale down as the "208x120>" implies.

What is that error, how do I fix it and why doesn't this command line work for larger images?

What I'm trying to do is rescale while keeping aspect ratio to around 208x120 then forcing paddding around any extra space to create an exactly 208x120 pixel image. Smaller images should just be place in the center without sizing up and larger images shrunk to the new size.

Re: ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-21T16:32:51-07:00
by fmw42
try placing -gravity center after -resize

do you have any virtual canvas with your image?

try

convert small_image.jpg +repage -resize '208x120>' -gravity Center -background white -extent 208x120 s_icon.gif

convert large_image.jpg +repage -resize '208x120>' -gravity Center -background white -extent 208x120 s_icon.gif

the +repage may or may not be necessary

see http://www.imagemagick.org/script/comma ... p#geometry and http://www.imagemagick.org/Usage/resize/#resize

P.S. Your command using the logo: image works fine for me on IM 6.5.6-3 Q16 Mac OSX Tiger

convert logo: -gravity Center -resize '208x120>' -background white -extent 208x120 logo_tmp1.png

Re: ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-21T16:57:43-07:00
by anthony
JPG's do not store any virtual canvas information.

It seems to work perfectly find for me.
Only larger images are resized, no cropping, white padding.

what does your Im say for

Code: Select all

   convert -version

Re: ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-21T21:55:10-07:00
by curlyman72
I tried what you suggested but I still get this:

convert: invalid geometry `'208x120' @ geometry.c/ParseRegionGeometry/1322.

The version I get when I do -version is:

Version: ImageMagick 6.5.6-4 2009-09-21 Q16 OpenMP

Re: ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-21T23:13:58-07:00
by anthony
The quoting seem to indicate some problem. Ar you using windows?
If so swicth your quote characters from ' to "

See IM Examples, Windows Scripting API
http://www.imagemagick.org/Usage/windows/

Re: ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-23T15:16:22-07:00
by curlyman72
Man. All this pain over a '

This issue seriously needs to be in the FAQ or in the manual somewhere in a conventions section or something. If it is, it surely needs to bubble up to the top.

Thanks guys for all the help.. this solved it!

Re: ImageMagick and Geometry Issue - resizing with >

Posted: 2009-09-23T16:08:31-07:00
by fmw42
FYI, it is in the file Anthony mentioned which is clearly listed and linked on his main page (at http://www.imagemagick.org/Usage) titled as Usage Under Windows. It says:

Most often, double quotes '"' have need to be used in place of single quotes ''' so that the command arguments remain correct. Watch out for quotes within quotes such as in "-draw" operator. You can use single quotes within a DOS double quoted argument as these are passed to IM for handling, and not the DOS scripting language.


Sorry I know little about Windows, but find Anthony's pages very helpful and try to point Windows users to this file when I recognize such an issue. Sorry if I did not catch that sooner. By habit even on Mac/Unix, I almost always use double quotes (to allow variables to be used inside them).