How to use PIL to resize and apply rotation EXIF information to the file?

Viewed 12961

I am trying to use Python to resize picture. With my camera, files are all written is landscape way.

The exif information handle a tag to ask the image viewer to rotate in a way or another. Since most of the browser doesn't understand this information, I want to rotate the image using this EXIF information and keeping every other EXIF information.

Do you know how I can do that using Python ?

Reading the EXIF.py source code, I found something like that :

0x0112: ('Orientation',
         {1: 'Horizontal (normal)',
          2: 'Mirrored horizontal',
          3: 'Rotated 180',
          4: 'Mirrored vertical',
          5: 'Mirrored horizontal then rotated 90 CCW',
          6: 'Rotated 90 CW',
          7: 'Mirrored horizontal then rotated 90 CW',
          8: 'Rotated 90 CCW'})

How can I use this information and PIL to apply it ?

3 Answers
Related