Sunday 15 August 2010

resize - ImageMagick losing aspect ratio -


Very easily I have a script that calls image magazines to my pictures.

The original image is 320 x 444, and I want to create some scale-down versions, but want to maintain the same aspect ratio

I call on ImageMagak

  convert oldfile.png -reize 290x newfile.png   

I want to scale it to my set width but scale accordingly .

I do 80x, 160x and 290x in 3 different commands.

Small 2 product images with the same basic aspect ratio, not 290x.

The size of the image it generates is 290 x 402

I do not know why it fails to maintain aspect ratio, but the other Maintains 2 sizes

Any ideas?

I think the problem with the third command is the requested size itself:

    < Li> In both orders, the two dimensions are divided by 4: 320/4 = 80 and 444/4 = 111
  1. In the second order Both dimensions are divided by 2: 320/2 = 160 and 444/2 = 222

    444 and 320 There are only two general dividers: 2 and 4. You already use these divisors in your first two orders, Therefore, any other (width, height) pairs will give you a different aspect ratio: it is impossible to get the correct aspect ratio fixing 290.

    In fact, while your original image has an aspect ratio of 1.3875 , with a 290x403 image you can see the 1,389655172 and a 290x402 With the image you will get a 1,386206897 ratio: Fixing 290 does not have any other dimension that can give you the desired aspect ratio. / P>

    In general, although imaging always tries to preserve the aspect ratio of the image, as you can read in the imagemagic documentation:

    The logic field of the resizing operator In which the image should be fit This field is not the final shape of the image, but the maximum size for the image is because it tries to preserve the aspect ratio of the IM image over the last (unless the '!' Flag is not given ), But at least one of the last dimensions (if not both), give the argument the image, then let me clarify ... the shape to be resized will fit the image in the shape. It does not fade, the requested box size

    For more context

No comments:

Post a Comment