diff --git a/processor.py b/processor.py index 53a5a28..3a05f54 100644 --- a/processor.py +++ b/processor.py @@ -47,19 +47,24 @@ def processImage(file, outputPath=None): } def rotateFromExifMetadata(image): - for orientation in ExifTags.TAGS.keys(): - if ExifTags.TAGS[orientation]=='Orientation': - break - exif=dict(image._getexif().items()) + try: + for orientation in ExifTags.TAGS.keys(): + if ExifTags.TAGS[orientation]=='Orientation': + break + exif=dict(image._getexif().items()) - if exif[orientation] == 3: + if exif[orientation] == 3: image=image.rotate(180, expand=True) - elif exif[orientation] == 6: + elif exif[orientation] == 6: image=image.rotate(270, expand=True) - elif exif[orientation] == 8: + elif exif[orientation] == 8: image=image.rotate(90, expand=True) - return image + return image + except (AttributeError, KeyError, IndexError): + # cases: image don't have getexif + print('unable to find orientation exif metadata') + pass def generateFilename(fileID, modifier, outputPath): filename = "{}_{}.{}".format(fileID, modifier, OUTPUT_EXTENSION)