Hi, We have our images in PNG format with 750x1050 dimension. We want to resize the images to a dimension 180x340, and the following command is not converting to the exact dimension, rather its covnerting to 180x250.
Command used: convert -resize 180x340
We have also used various options like : –trim –geometry 180x340! -resize 180x340, which is stretching the image.
Pls let me know the right command to convert the image to this desired format. Appreciate your response.
Resizing image to a dimension
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resizing image to a dimension
convert in.png -resize 180x340! out.png
See http://imagemagick.org/script/command-l ... php#resize , and the link to Image Geometry.
See http://imagemagick.org/script/command-l ... php#resize , and the link to Image Geometry.
snibgo's IM pages: im.snibgo.com
Re: Resizing image to a dimension
I have tried the following command., and its stretching the image to vertical. Basically its a Wine bottle image, i thought of attaching here but there is no option to attach image in this forum.
convert in.png -resize 180x340! out.png
convert in.png -resize 180x340! out.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resizing image to a dimension
Well, that's what you said you wanted.
You can upload files to somewhere like dropbox.com and paste the URL here.We want to resize the images to a dimension 180x340, ...
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing image to a dimension
Using the ! tells IM to ensure that the size is exactly as specified even if it distort the image. If you want no distortion and aspect ratio preserved, either leave it off and pad or use ^ and crop or extent. See180x340!
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/Usage/thumbnails/#pad
http://www.imagemagick.org/Usage/thumbnails/#cut
see various options at
http://www.imagemagick.org/Usage/crop/
http://www.imagemagick.org/Usage/thumbnails/#creation
You can use -resize rather than -thumbnail
Re: Resizing image to a dimension
Thanks for the response.
I have uploaded the original image with dimension 750x1050 in the following location -
https://www.dropbox.com/s/anjp9o6qbqeoi ... n.png?dl=0
The desired dimension 180x340, converted using Photoshop is uploaded here -
https://www.dropbox.com/s/0x0ncyjtkzsnt ... 0.png?dl=0
The dimension 180x340, converted using Imagemagick with command 'convert -resize 180x340!' uploaded here
https://www.dropbox.com/s/uheezikwl3fi3 ... 0.png?dl=0
The imagemagick converted image is stretched as its ignored the aspect ratio. I am looking for the right command that converts to desired format 180x340 with no distortion to the image. Thanks for your help
I have uploaded the original image with dimension 750x1050 in the following location -
https://www.dropbox.com/s/anjp9o6qbqeoi ... n.png?dl=0
The desired dimension 180x340, converted using Photoshop is uploaded here -
https://www.dropbox.com/s/0x0ncyjtkzsnt ... 0.png?dl=0
The dimension 180x340, converted using Imagemagick with command 'convert -resize 180x340!' uploaded here
https://www.dropbox.com/s/uheezikwl3fi3 ... 0.png?dl=0
The imagemagick converted image is stretched as its ignored the aspect ratio. I am looking for the right command that converts to desired format 180x340 with no distortion to the image. Thanks for your help
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing image to a dimension
Your original image has an aspect ratio of 750/1050=0.714285714285714. You want an image with aspect ratio of 180/340=0.529411764705882. These are two very different aspect ratios. There is no way to do that without distorting, padding or cropping. The best I can suggest is
or
The latter seems to match the PS result, but may not be what you want in all cases, since it may crop parts of the object and not just background as it does in this case.
Code: Select all
convert OriginalDimension.png -resize 180x340 -gravity center -background none -extent 180x340 im_padded.png
Code: Select all
convert OriginalDimension.png -resize 180x340^ -gravity center -background none -extent 180x340 im_cropped.png
Re: Resizing image to a dimension
Thanks for the response.
On the 2nd command, is there a way it can be zoomed in, so that the size of the bottle can be little bigger. Below are the image links
The im_cropped.png
https://www.dropbox.com/s/5moln3h236max ... d.png?dl=0
PS converted image
https://www.dropbox.com/s/0x0ncyjtkzsnt ... 0.png?dl=0
On the 2nd command, is there a way it can be zoomed in, so that the size of the bottle can be little bigger. Below are the image links
The im_cropped.png
https://www.dropbox.com/s/5moln3h236max ... d.png?dl=0
PS converted image
https://www.dropbox.com/s/0x0ncyjtkzsnt ... 0.png?dl=0
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resizing image to a dimension
Try
where X is slightly larger than 100 as appropriate for the desired zoom.
Or just multiply 180 and 340 by X as a fraction (slightly larger than 1) and use those as
where W=180*X and H=340*X
Code: Select all
convert OriginalDimension.png -resize 180x340^ -resize X% -gravity center -background none -extent 180x340 im_cropped.png
Or just multiply 180 and 340 by X as a fraction (slightly larger than 1) and use those as
Code: Select all
convert OriginalDimension.png -resize WxH^ -gravity center -background none -extent 180x340 im_cropped.png