.resize() with .max() still crops the image
See original GitHub issueSorry to bother you again, dunno - maybe its something on my side. Given an image - for example this one
I would like to resize it to max 100x100 which means the resulting image should fit within those bounds while maintaing the aspect ratio (no cropping). Here’s my call:
sharp(file).resize(100, 100).max().toBuffer(function(err, buffer) {
});
And the image I get is this one (resized and cropped to 57x100):
Shouldn’t sharp
simply resize input image to 57x100 without any cropping?
Thanks.
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Dynamically Resizing and Cropping Images - Cloudinary
Learn how to use different resize and crop modes together with various gravity options to transform images dynamically.
Read more >Advanced cropping, resizing, resampling - Adobe Support
This document explains in detail how cropping, resizing, and resampling images affects image resolution and pixel dimensions in Adobe ...
Read more >Pillow crop images keeping the ratio having a max width and ...
I need to crop something using Pillow, by keeping the ratio, and max_height or max_width. Some images can have a bigger width or...
Read more >How to resize an image in HTML? - ImageKit.io
You can use the object-fit CSS property on the img element to specify how the image should be resized & cropped to fit...
Read more >Resize Images Proportionally While Keeping The Aspect Ratio
We can resize images proportionally with HTML image tags or CSS background ... Use max-width: 100% to limit the size but allow smaller...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hmmm, I tried on an OSX Mav with sharp 0.4.1, libvips 7.38 and both node 0.10/0.11. Here’s what i get
What’s your platform ?
@pierreinglebert: I get the same results as you with that image, though I do see unexpected cropping with a different image. Perhaps Github is reencoding attachments and that changes something.
Here is a source image I can use to repro: https://mega.co.nz/#!UUNSCJxB!lBzVsklJX0VqtsOTYPi7NhGeOoZrqywMwPqUuLoMTIs
This is what the unexpected cropping looks like (100x100, max):
My setup: