Sorry 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.
That definitely doesn't look right. The max() option was only added very recently.
@pierreinglebert are you able to help Przemek with this?
+1 I see similar behavior too.
I'll look at it.
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

var sharp = require('sharp');
var fs = require('fs');
sharp('f2bc5c0e-e1ec-11e3-844f-28e9fded8f8b.png').resize(100, 100).max().toBuffer(function(err, buffer) {
fs.writeFileSync('out.jpg', buffer);
});
What's your platform ?
It works flawlessly for PNGs but the problem is with JPEGs. This is the original image (JPEG) which fails as described in this issue:
http://upload.wikimedia.org/wikipedia/de/2/24/Burgon_Portrait.jpg
@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:
$ sw_vers -productVersion
10.9.3 # Mavericks
$ node --version
v0.10.27
$ npm list
...
โโโฌ [email protected]
$ brew info vips
vips: stable 7.38.5
http://www.vips.ecs.soton.ac.uk/
/usr/local/Cellar/vips/7.38.5 (188 files, 13M) *
Built from source with: --with-webp, --with-graphicsmagick
From: https://github.com/homebrew/homebrew-science/commits/master/vips.rb
==> Dependencies
Build: pkg-config โ
Required: fontconfig โ, gettext โ, glib โ
Recommended: libpng โ, jpeg โ, orc โ, libtiff โ, fftw โ, little-cms โ, pango โ, libexif โ
Optional: openslide โ, imagemagick โ, graphicsmagick โ, openexr โ, cfitsio โ, webp โ
If you're seeing differing behaviour between PNG and JPEG images then my best guess would be that this is due to the use of libjpeg's shrink-on-load feature. If used, there's a recalculation of the further transformations that might need some max-specific logic.
Thanks, as always, for the fix @pierreinglebert .
@matylla and @ide are you able to verify the max logic in the master branch behaves as you expect? If so, I'll publish this fix to to npm. Cheers!
@lovell - the output from master looks correct to me:

Thank you guys for the prompt fix!
Yes, it looks correct on my side. Can u bump up the version and push to npm?
Thanks all - v0.4.2 now published to npm - https://www.npmjs.org/package/sharp
Most helpful comment
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 ?