Resizes an image to a specific size and dealing with aspect

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
vijayamaladoss

Resizes an image to a specific size and dealing with aspect

Post by vijayamaladoss »

Hi,
I am trying to convert a image from 500X280 (16:9) to a specific box size of 377x248. I am using the resize and crop methodlogy and below is my command.

Code: Select all

convert 16_9.jpg -filter lanczos -resize 248x248^ -gravity center -crop 377x248+0+0 +repage 16_9_res.jpg
But the resultant images has the dimensions 248x139. I thought the idea of the above command to deal with aspect change and I saw the same things from Fred's script also.

http://www.fmwconcepts.com/imagemagick/aspect/index.php

Am I missing something ? Thanks a lot for your reply

PS: I am running on windows XP with ImageMagic 6.5.1-4 (Latest I think)
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Resizes an image to a specific size and dealing with aspect

Post by Bonzo »

I would leave out the width in your case so -resize 248x248^ becomes -resize x248
Either way you need to escape the ^ with another ^ so it would be -resize 248x248^^
See http://www.imagemagick.org/Usage/api/

Try:

Code: Select all

convert 16_9.jpg -filter lanczos -resize x248 -crop 377x248+0+0 +repage 16_9_res.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resizes an image to a specific size and dealing with aspect

Post by fmw42 »

try either

convert rose_tmp1.png -resize 248x248\^ -gravity center -crop 377x248+0+0 +repage rose_tmp2.png

or

convert rose_tmp1.png -resize '248x248^' -gravity center -crop 377x248+0+0 +repage rose_tmp2.png


If on windows: you must escape the ^ with another ^ rather than a \
vijayamaladoss

Re: Resizes an image to a specific size and dealing with aspect

Post by vijayamaladoss »

Wow, Thanks a lot for your quick reply. That worked as a charm :D
Post Reply