Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.resize() crops image when crop is unnecessary #831

Closed
max-degterev opened this issue May 30, 2017 · 6 comments
Closed

.resize() crops image when crop is unnecessary #831

max-degterev opened this issue May 30, 2017 · 6 comments
Labels
Milestone

Comments

@max-degterev
Copy link

max-degterev commented May 30, 2017

I'm having trouble with resize function cropping sides of the image when only resize is needed:

// assume expressjs middleware
const resizeTransform = sharp().resize(/* either numbers or undefined-s from querystring */);
const downloadStream = request(req.query.src);
req.pipe(downloadStream).pipe(resizeTransform).pipe(res);

passing along width=200 produces this image:
image

However passing 199 or 201 produces expected result:
image-2

original:
arnold-transformation-challenge-1-600x399-1

Seems like some strange bug to me. I was expecting to always get a downscaled image in the original aspect ratio. I couldn't find anything in the documentation regarding controlling the crop. How does one achieves resizing this without cropping, and only having crop when both width and height are present?

I already tried converting to JPEG first, passing both dimensions and playing with .max, .min methods, no luck.

Running node v6.10.2, sharp v0.18.0

@lovell
Copy link
Owner

lovell commented May 30, 2017

Hello, I'm currently investigating a problem with JPEG shrink-on-load that appears to have been introduced in v0.18.0 and I believe this is related. v0.17.3 works as expected.

@lovell lovell added the triage label May 30, 2017
@max-degterev
Copy link
Author

max-degterev commented May 30, 2017

@lovell ah thank you, I will try downgrading to v0.17.3 and check can confirm that it works as expected with v0.17.3

@lovell
Copy link
Owner

lovell commented May 30, 2017

Commit 9e39a7f fixes the problem I've been investigating. Are you able to confirm the latest code on the master branch fixes things for you too?

@lovell
Copy link
Owner

lovell commented May 30, 2017

...and commit f42a1ce fixes it properly, adding your test case too, thanks for reporting this.

@lovell lovell added bug and removed triage labels May 30, 2017
@lovell lovell added this to the v0.18.1 milestone May 30, 2017
@lovell
Copy link
Owner

lovell commented May 30, 2017

These fixes are in v0.18.1 now available via npm. Please re-open if you're still having related problems.

@lovell lovell closed this as completed May 30, 2017
@max-degterev
Copy link
Author

Just checked with v0.18.1 and it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants