covert to specific width.

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

covert to specific width.

Post by DannyGM »

Hello.

I am using this:
convert src-img -resize 300X dest-img

to convert any image to 300px width.
My question is, how can I crop the "dest-img" image that it's will never be more than 500px height?

convert src-img -resize 300!X(max 500px)

Thank you.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: covert to specific width.

Post by fmw42 »

DannyGM wrote:Hello.

I am using this:
convert src-img -resize 300X dest-img

to convert any image to 300px width.
My question is, how can I crop the "dest-img" image that it's will never be more than 500px height?

convert src-img -resize 300!X(max 500px)

Thank you.

try:

convert src-img -resize '300x300^' -gravity center -crop 300x500+0+0 +repage dest-img

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

if you are on windows, also see http://www.imagemagick.org/Usage/api/#windows
DannyGM

Re: covert to specific width.

Post by DannyGM »

Thank you.

I think that it's going to work.

I try it.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: covert to specific width.

Post by anthony »

Almost that could still make the image width smaller that 300 pixels.

Use -resize 300x to gurantee 300pixel width, then use -crop to limit the height. or -extent to always set the height.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply