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

Rotation on image with height not evenly divisible leads to artifacts #23

Open
mixmastamyk opened this issue Feb 19, 2019 · 1 comment

Comments

@mixmastamyk
Copy link

So I have a jpeg image that is 1932x2576 in resolution.

Not sure how it got those dimensions, perhaps by being cropped. I used your library to rotate/normalize the orientation, as it should be landscape. Exif says orientation: 6.

The incorrect result was that ~10 pixels of the left of the image were copied to the right edge of the photo and it wasn't rotated.

I restored from backup, opened it in gthumb instead, and chose "rotate physically." This worked correctly, so believe it is something to do with this library or module.

This library worked fine on my other images, and so far this is the only image that showed the problem.

If I had to guess it has something to do with the fact that the width is not evenly divisible by 8/16.

>>> 1932/8
241.5

>>> 1932/16
120.75

>>> 2576/8
322.0

Thanks for your help.

@cbm755
Copy link
Collaborator

cbm755 commented Apr 17, 2020

I believe this is a fundamental limitation of most lossless jpeg operations.

Quoting jpegtran man page:

other transformations operate rather oddly if the image
dimensions are not a multiple of the iMCU size (usually 8 or 16 pix‐
els), because they can only transform complete blocks of DCT coeffi‐
cient data in the desired way.

Feature request: it would be nice if this library warned us about this, and offered an option to trim like the jpegtran command line utility.

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