-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
smartcrop: bad extract area #1134
Comments
Hi Michal, thank you for this detailed report and accompanying test repository. The "attention" and "entropy" crop strategies rely on the I think the best fix here is for sharp to ignore the strategy choice should either width or height be missing as that situation will result in no crop taking place anyway. I'll take a look at this. |
When resizing with just width (or height) crop strategy/gravity shouldn't have any effect - it's just scaling without cropping, right? What I find weird is that it works fine (doesn't throw error) with some width (f.e. 1120px or 1100px in my example) and not with others (1110px). I will add conditional check to not use |
…y when just scaling workaround for bug in sharp lovell/sharp#1134
…y when just scaling (#4174) workaround for bug in sharp lovell/sharp#1134
This error occurs when cumulative rounding during the resize operation occasionally produces an image 1px smaller along one edge than the expected target dimensions. The bug here is that there's no conditional guard to prevent a "smartcrop" operation taking place when the image is already small enough. I've added your example dimensions as a new unit test locally, which currently fails, and expect to push the fix that will get this test to pass within the next 24 hours. Thanks for reporting! |
v0.19.1 now available with the fix for this. |
@ralrom Please can you open a new issue with a minimal code sample (using only sharp) that exhibits this behaviour. |
In very specific case resizing with cropping set to
sharp.strategy.attention
orsharp.strategy.entropy
will result with errorsmartcrop: bad extract area
Repository to reproduce - https://github.com/pieh/sharp-smartcrop-bad-extract-area-repro
This happens when
width
is set to1110
andheight
is unspecified using image from above repository (it is 1600 x 1200)In readme of repository I placed more outputs where it works fine:
sharp.gravity.center
1120
and1100
respectively)This was originally reported in gatsbyjs/gatsby#4142 (just to keep paper trail - reproduction repository should be enough)
The text was updated successfully, but these errors were encountered: