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

Plugin crop/fix safety checks #743

Merged

Conversation

janikga
Copy link

@janikga janikga commented May 23, 2019

What's Changing and Why

  • safety checks for the width and height of remainingPixels are moved behind the pixelsToCrop sanitization, otherwise they lead to wrong values if the pixelsToCrop are negative

I encountered this in the following use case:

  • when calling the autocrop function on an image, I specified a leaveBorder value that was larger than the number of pixels that were cropped from the image. This lead to incorrect values for widthOfRemainingPixels and heightOfRemainingPixels, as they use the negative values of pixelsToCrop instead of the sanitized ones.

leaveBorder is applied here:

https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/plugin-crop/src/index.js#L209-L213

safety checks are applied here:

https://github.com/oliver-moran/jimp/blob/736054ef1bea6b6fb03db3e75f05cd922a9c104f/packages/plugin-crop/src/index.js#L224-L234

Moving the safety checks behind the sanitization leads to correct values.

Note: I was not able to build and test locally, due to this issue.

What else might be affected

  • only the crop plugin is affected

Tasks

  • Add tests
  • Update Documentation
  • Update jimp.d.ts
  • Add SemVer Label

@janikga
Copy link
Author

janikga commented Jul 24, 2019

is this repo dead? 😢

@hipstersmoothie
Copy link
Collaborator

@jagaSto please rebase so the CI runs. Getting this project set up with good CI/CD has been an issue. but now we have circleci setup (I think) so it should be easier to mange the project!

@janikga
Copy link
Author

janikga commented Aug 22, 2019

thx for the hint @hipstersmoothie, will fix the tests once I find the time.Do you have any insights into #742 ? Running the tests locally is not working for me, which will make the process of debugging a bit more painful 🙃 Edit: tests run now locally

@janikga
Copy link
Author

janikga commented Aug 27, 2019

@hipstersmoothie this is fixed now!

@hipstersmoothie hipstersmoothie added the patch Increment the patch version when merged label Sep 3, 2019
@hipstersmoothie hipstersmoothie merged commit 67320bd into jimp-dev:master Sep 3, 2019
@hipstersmoothie
Copy link
Collaborator

🚀 PR was released in v0.6.7 🚀

@hipstersmoothie hipstersmoothie added the released This issue/pull request has been released. label Sep 3, 2019
@janikga janikga deleted the plugin-crop/fix-safety-checks branch October 9, 2019 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants