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

Rounding issues in getPixelCrop #167

Closed
MaciejM92 opened this issue Mar 26, 2018 · 3 comments
Closed

Rounding issues in getPixelCrop #167

MaciejM92 opened this issue Mar 26, 2018 · 3 comments

Comments

@MaciejM92
Copy link

Hi, good job with the lib! I think I have an idea for improvement as it comes to outputting the pixel values in onComplete callback. Right now it is possible to receive boundaries outside of the original image surface:

  1. Use image 1000px width and 666px tall
  2. Try to crop with 16/9 ratio, full width
  3. Place the crop area to the very bottom

The problem here is that when using Math.round you may end up with y=104px and the height=563px. This is one pixel outside the original surface. I'd suggest using Math.floor and Math.ceil instead. My suggestion would be to use floor for the x and y values while using ceil for width and height in getPixelCrop.

Let me know your thoughts.

@sekoyo
Copy link
Owner

sekoyo commented Mar 26, 2018 via email

@sekoyo
Copy link
Owner

sekoyo commented Mar 27, 2018

Should be fixed in 3.0.11

@MaciejM92
Copy link
Author

🎉 Thank you!

@sekoyo sekoyo closed this as completed Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants