Making box image for any image

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?".
Post Reply
DannyGM

Making box image for any image

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making box image for any image

Post 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
DannyGM

Re: Making box image for any image

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making box image for any image

Post 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
Post Reply