convert -resize not working properly

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
stoopkid1
Posts: 2
Joined: 2013-01-23T14:24:42-07:00
Authentication code: 6789

convert -resize not working properly

Post by stoopkid1 »

hi all, i'm new to the board and absolutely love the command line ability with this software. i'm working with PHP and utilizing it's exec('') functionality. all i'm trying to do is resize an image, but i don't believe it's working properly. my original image is 1024x1026, and i am trying to resize the image to 1710 x 2200. the command i'm running is:

Code: Select all

convert -resize 1710x2200 c:\test\hpaa.jpeg c:\test\hpaa1.jpeg
the resulting image (hpaa1.jpeg) comes out to only 1710x1713. am i misusing the command, or is there another parameter i'm missing? i need the standardized image size (1710x2200) because the software my company is working on depends on that exact size (or something VERY close to it). any and all help is appreciated.

thanks.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: convert -resize not working properly

Post by Bonzo »

You need to read the image in first:

Code: Select all

convert c:\test\hpaa.jpeg -resize 1710x2200 c:\test\hpaa1.jpeg
As to size - do you want to distort the image to fit the new size, do you want to crop the image to fit the new size, do you want to get the longest dimension to fit the new size and keep the aspect ratio or pad the image out with a background colour to fit the new size?

The resize options are here http://www.imagemagick.org/script/comma ... p#geometry and if you want differnt result like a crop or pad you will need to explain what result you would like.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert -resize not working properly

Post by snibgo »

If you want exactly 1710x2200, you need an exclamation mark. I use Windows, so the exclamation mark need to be escaped with a caret:

Code: Select all

convert c:\test\hpaa.jpeg -resize "1710x2200^!" c:\test\hpaa1.jpeg
snibgo's IM pages: im.snibgo.com
stoopkid1
Posts: 2
Joined: 2013-01-23T14:24:42-07:00
Authentication code: 6789

Re: convert -resize not working properly

Post by stoopkid1 »

snibgo wrote:If you want exactly 1710x2200, you need an exclamation mark. I use Windows, so the exclamation mark need to be escaped with a caret:

Code: Select all

convert c:\test\hpaa.jpeg -resize "1710x2200^!" c:\test\hpaa1.jpeg
I'm on Windows as well snibgo. Thanks very much for both of your insights on my issue. I figured it was a fundamental problem I was having with the command, and not using it properly. Thank you for pointing out how to fix my problem. I'll give it a shot later this evening and report my results.
Post Reply