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

EXIF rotation information lost #11

Open
laurivosandi opened this issue Jul 2, 2016 · 5 comments
Open

EXIF rotation information lost #11

laurivosandi opened this issue Jul 2, 2016 · 5 comments

Comments

@laurivosandi
Copy link

Hi,

it seems JPEG images with EXIF rotation info are messed up after resizing. This can be easily fixed by rotating the image after resizing based on the information found in EXIF tags:

try:
    from exifread import process_file # This is for newer Ubuntus
except ImportError:
    from EXIF import process_file # This is for Ubuntu 14.04

tags = process_file(open("path/to/filename.jpg"))
orientation = tags.get("Image Orientation")

if orientation:
    j, = orientation.values
    if j == 6:
        print "rotated 270 degrees"
    elif j == 8:
        print "rotated 90 degrees"
    elif j == 3:
        print "rotated 180 degrees"

Also to speed up resizing/rotation you could take a look at epeg at https://github.com/mattes/epeg

@vinyll
Copy link
Owner

vinyll commented Apr 2, 2018

Hey @laurivosandi! It's been a while you reported this issue but I couldn't understand it.
I might start to comprehend your point here. Probably you've been over it, but your knowledge may be useful here.

Do you think this issue on Neomad and this one from the Medium Editor Plugin could be also for the same reason?

@laurivosandi
Copy link
Author

Hi, yes this looks exactly like the same issue

@laurivosandi
Copy link
Author

The point is JPEG data orientation doesn't have to match the orientation it is supposed to be shown in. EXIF tags show you the intended orientation.

@vinyll
Copy link
Owner

vinyll commented Apr 3, 2018

Some hint based on the current library used in Imagefit: https://stackoverflow.com/a/6218425/328117
This seems simple enough to be implemented.

@vinyll
Copy link
Owner

vinyll commented Apr 9, 2018

Wondering if we should reorient the picture or just pass EXIF metadata.
I was working on the first option, but second might make more sense as it preserves a little more the original data.

Any opinion @laurivosandi ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants