Skip to content

EXIF rotation information lost #11

@laurivosandi

Description

@laurivosandi

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions