imdirect

PIL extension performing automatic rotation of opened JPEG images


License
MIT
Install
pip install imdirect==0.5.0

Documentation

imdirect

Build Status Coverage Status

The orientation of the photographed object or scene with respect to the digital camera is encoded in the resulting image's Exif data (given that it is saved as a JPEG).

When working with such digital camera images, this orientation might lead to problems handling the image and is very often desired to be counteracted. This module is a small extension to Pillow, adding an autorotate method that can be used for addressing this issue.

It will eventually feature a PIL.Image.Image subclass that autorotates internally and updates and ports Exif data when saving the image to new file.

Installation

pip install git+https://www.github.com/hbldh/imdirect

Usage

In [1]: import imdirect

In [2]: from PIL import Pillow

In [3]: img = Image.open('2016-08-28 15.11.44.jpg')

In [4]: imdirect.determine_orientation(img)
Out[4]: 6

In [5]: img
Out[5]: <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=4032x3024 at 0x7F3DFD950990>

In [6]: imdirect.autorotate(i)
Out[6]: <PIL.Image.Image image mode=RGB size=4032x3024 at 0x7F3DFD89CED0>

Tests

TBD.