-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
1px black line added when cropping #551
Comments
Same problem, any progress? |
Same problem, add transparent line |
This may cause by flooring float numbers to integer numbers, may need to refactor the cropper on numbers normalizing. |
+1 |
Same problem :(. Anyone have any solution? |
I dealt with this manually. This phenomenon occurs if the width of the picture is odd. If the width of an image is odd, then manually reduce the width of the image by 1 and reduce the height by the number of pixels. |
What I did is set a bounding box for the cropbox to move in. That leaves some space around the edges. If it comes 1 pixel short it doesn't cause directly the black line to appear but still has a piece of the image to use. P.S. I didn't use this crop tool but my crop tool has the same issue some time, hope my method can help some one out. |
The PR #300 does fix the issue... |
I tried to short 1px of the width, and 1px of height, but It seemed to not solve the problem, It still remains 1px black line |
Same problem, any progress? |
1 similar comment
Same problem, any progress? |
Can we get some more information on the "odd number of pixels" fix. Apparently nobody is going to take action on this and I'd like to resolve it. In my case, I export the files as PNG images with transparency, then detect if any pixels are transparent before saving as either png or jpg.... and it often saves as png inadvertantly because of the extra transparent pixels |
Which numbers specifically, and what would a good fix be. I'm almost to the point of writing a "post crop" function to go through all the pixels on the edges to detect if this happened (all transparent pixels on the edges) and simply remove them. That's a bad solution, but it's about all I've got without an update |
Is there a built version of this PR implemented where I could implement and do QA testing? I normally use the built JS files. It appears the PR hasn't been pulled and implemented in source yet... Any idea when/if this is going to happen? |
@collinph You can test with my build on npm (@daiyam/cropperjs, source) which include the PR. |
Do I need to enable the precisePreview option to fix the current bug? |
@collinph yes |
The PR #1047 fix the issue for me. |
For those who are looking for a "solution". I'm removing 1 pixel from height or width when i'm hitting an uneven pixel value. // If the width or height is uneven remove 1 pixel. Otherwise a black line will appear on the right or bottom.
// https://github.com/fengyuanchen/cropperjs/issues/551
if (cropper.getCroppedCanvas().width % 2 !== 0) {
cropper.setData({
width: cropper.getCroppedCanvas().width - 1,
})
}
if (cropper.getCroppedCanvas().height % 2 !== 0) {
cropper.setData({
height: cropper.getCroppedCanvas().height - 1,
})
} |
As of v1.6.0, you can use the const canvas = cropper.getCroppedCanvas({
rounded: true,
}); |
fix lichess-org#15782 There are various bug/issues related to the cropperjs lib with transparency fengyuanchen/cropperjs#551 fengyuanchen/cropperjs#1072 so had to bypass it and keep the original image.
same problem on v1.6.0. |
I tried last 1.5.4 version as well as 2.0.0-alpha, but the problem is always the same.
Used settings:
Image used to test with the above settings:
Result cropped image:
The text was updated successfully, but these errors were encountered: