imaginary icon indicating copy to clipboard operation
imaginary copied to clipboard

/resize aspect ratio is not being maintained

Open foobargeez opened this issue 6 years ago • 4 comments

I have an image with 1529x2500 dimensions and I am calling imaginary as follows:

https://<imaginary host>/resize?file=test/test.jpg&width=960&stripmeta=true&quality=70

The output image has 960x2500 dimensions and I am expecting the output image dimensions to be 960x1570. Any idea how to make imaginary honor the aspect ratio?

Thanks!

foobargeez avatar Jan 06 '19 22:01 foobargeez

BTW, if imaginary doesn't (want to) honor the aspect ratio, I can pass the height too (which is what I currently do to workaround) but the doc says, imaginary takes aspect ratio into account, so just making sure I understand what to expect.

foobargeez avatar Jan 07 '19 11:01 foobargeez

Imaginary should actually respect the aspect-ratio, but this part is a tad bit confusing. Try specifying the nocrop=true parameter and omit the height.

This works for me:

http://localhost:9000/resize?width=400&nocrop=true&stripmeta=true&quality=70&url=https%3A%2F%2Fimages.unsplash.com%2Fphoto-1546662654-5029c0524efa%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1834%26q%3D80

P.s. Sorry for closing the issue, I fat-fingered it.

Dynom avatar Jan 07 '19 12:01 Dynom

Specifying nocrop=true is respecting the aspect ratio. This workaround works for me (unless this is default behavior in which case, we should clarify in the doc).

foobargeez avatar Jan 07 '19 17:01 foobargeez

I agree it is and I think it can even be considered a bug, but we need to dive into that first. With image manipulation things aren't always that simple :-)

Dynom avatar Jan 10 '19 13:01 Dynom