Page 1 of 1

Making box image for any image

Posted: 2009-01-17T12:38:44-07:00
by DannyGM
Hello.
Sorry about my grammar, English isn't my tang.

Thank you to for you help me in the past.

My question is how I make a box image (Ex: 100X100px) from any size or dimensions of image.
I mean If the source image is 130x40 I want ImageMagick to resize&crop it so the dest that I get will be 100X100
I don't want to change the aspect ratio of the image, I want to resize&crop to the center.

I am using convert.exe command line, or ImageMagickObject COM+.

Thank you.

Re: Making box image for any image

Posted: 2009-01-17T13:39:34-07:00
by fmw42
try

convert inputimage -resize 100x100^ -gravity center -crop 100x100+0+0 +repage outputimage

see -resize and image geometries about the use ^ for making the smaller dimension resize to 100.
http://www.imagemagick.org/script/comma ... p#geometry

also see http://www.imagemagick.org/Usage/api/#windows regarding special escape characters for windows.

so for windows this likely needs to be either

convert inputimage -resize 100x100^^ -gravity center -crop 100x100+0+0 +repage outputimage

or

convert inputimage -resize "100x100^" -gravity center -crop 100x100+0+0 +repage outputimage

Re: Making box image for any image

Posted: 2009-01-17T16:28:59-07:00
by DannyGM
Great! :lol:
Thank you.

This is the command, that solve my problem:

Code: Select all

convert candelete.jpg  -resize "100X100^" -gravity center -crop 100X100+0+0 win:
It's working.

Thank you.

Re: Making box image for any image

Posted: 2009-01-17T17:10:03-07:00
by fmw42
DannyGM wrote:Great! :lol:
Thank you.

This is the command, that solve my problem:

Code: Select all

convert candelete.jpg  -resize "100X100^" -gravity center -crop 100X100+0+0 win:
It's working.

Thank you.
You should keep the +repage at the end to avoid the virtual canvas size being different from the image, so that further processing does not have errors.

see
http://www.imagemagick.org/script/comma ... php#repage