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
Comments
Hi,
Thanks for raising this good point. Your solution sounds good, or
alternatively clamping the width and height to remain in bounds as we have
the image node (clamp(x + width), imageWidth)). But off the top of my head
I think your idea would work too, will give it a think
…On Mon, 26 Mar 2018 at 11:51, MaciejM92 ***@***.***> wrote:
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#167>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAuZ-pydg2nAVU6xmhe-pty2iRClAtvzks5tiMhCgaJpZM4S66HC>
.
|
sekoyo
added a commit
that referenced
this issue
Mar 26, 2018
Should be fixed in 3.0.11 |
🎉 Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: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 usingMath.floor
andMath.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.
The text was updated successfully, but these errors were encountered: