Open saravanakumar38 opened 7 years ago
We are looking for alternatives for ngx_small_light and we have same requirement.
The work-around is by doing this client-side. If you know the dimensions you can decide what to do, this also empowers you to deal with the side you want to crop.
Imaginary supports maintaining an aspect ratio, by not specifying one of the sides. If you specify both width & height, you're telling Imaginary that you know what you're doing. I think you get the result you want by only specifying the longest side.
See also: https://github.com/h2non/imaginary/issues/135#issuecomment-302696540
Just a side note. This is possible with gm and sharp. Both can be used to get dimensions of an image to use it with imaginary, but they can resize it too. We stick with sharp (which use libvips too), because it meets all our current requirements, partially resizing with keeping aspect ratio, performance and memory footprint (important for lambda on aws).
Hi,
I tried to resize the image (640x480) to 185x110, but resize image is missing portion of the original image. I tried with thumbnail, but images is stretched. How can we resize the image automatically based on aspect ratio. example if original image size (640x480) and resize parameter is (185x110), imaginary should automatically convert to (146x110).
var ratioX = (double)requestedResizeWidth / OriginalWidth; var ratioY = (double)requestedResizeHeight / OriginalHeight; var ratio = Math.Min(ratioX, ratioY);
I have attached sample image for reference. Is there best method to get resized image without missing image content?
Thanks