You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cropped images are sometimes 1 pixel too small #123
When I run this command on kitty.jpg from the test suite, the output image is 99x400.
I assume this happens because of the skewed aspect ratio of the requested crop, I've encountered a similar "missing pixel" problem when cropping in Photoshop. Is there a way to force exact dimensions for the output?
Hey @wave-dash thanks for the detailed report. I don't think this is the correct repo though. Can you please report it against https://github.com/jwagner/smartcrop-cli ? Looks like a rounding error somewhere. I don't have time to go digging for it right now but I should get to it eventually. :)
In the first pair of lines, I believe you are scaling down the dimensions for the downsampled image (for processing ease, I'm assuming). But since it's floored, once you scale back up in the second pair of lines, it won't be at the correct width, especially if the initial wasn't a multiple of 256.
I don't know what the solution should be. You could force based on aspect ratio. But as an end user, I guess I can just use the x and y of the crop, and force the dimensions myself.
Just letting you know where I think the issue lies.
Activity
jwagner commentedon Mar 20, 2023
Hey @wave-dash thanks for the detailed report. I don't think this is the correct repo though. Can you please report it against https://github.com/jwagner/smartcrop-cli ? Looks like a rounding error somewhere. I don't have time to go digging for it right now but I should get to it eventually. :)
wave-dash commentedon Mar 21, 2023
Sure thing, sorry about that. This repo seemed more active, and I figured the code for the two would be mostly the same.
kamiyo commentedon Aug 6, 2023
I actually have a similar problem using smartcrop-sharp. When passing it options like this:
OR
It always returns a height of 2656 instead. I think the issues are here:
smartcrop.js/smartcrop.js
Lines 120 to 121 in de2d143
smartcrop.js/smartcrop.js
Lines 147 to 148 in de2d143
In the first pair of lines, I believe you are scaling down the dimensions for the downsampled image (for processing ease, I'm assuming). But since it's floored, once you scale back up in the second pair of lines, it won't be at the correct width, especially if the initial wasn't a multiple of 256.
To prove the above example in pseudocode,
I don't know what the solution should be. You could force based on aspect ratio. But as an end user, I guess I can just use the x and y of the crop, and force the dimensions myself.
Just letting you know where I think the issue lies.