PaletteOptimiser

Changeset

15:e9fa3d280806
2015-09-09 Paul Boddie raw files shortlog changelog graph Added automatic rotation detection.
optimiser.py (file)
     1.1 --- a/optimiser.py	Wed Sep 09 01:05:04 2015 +0200
     1.2 +++ b/optimiser.py	Wed Sep 09 14:38:40 2015 +0200
     1.3 @@ -1,6 +1,7 @@
     1.4  #!/usr/bin/env python
     1.5  
     1.6  from array import array
     1.7 +import EXIF
     1.8  import PIL.Image
     1.9  import sys
    1.10  
    1.11 @@ -43,8 +44,9 @@
    1.12      scaled_filename = (sys.argv[3:] + [None])[0]
    1.13      rotate = "-r" in sys.argv[3:]
    1.14  
    1.15 +    x = EXIF.process_file(open(input_filename))
    1.16      im = PIL.Image.open(input_filename)
    1.17 -    if rotate:
    1.18 +    if rotate or x["Image Orientation"].values == [6L]:
    1.19          im = im.rotate(270)
    1.20      w, h = im.size
    1.21      height = (width * h) / w