mirror of
https://github.com/KevinMidboe/leifs-image-processor.git
synced 2025-10-29 17:50:20 +00:00
Fixed indentation and added exception handler for when we dont find a orientation variable in the exif metadata.
This commit is contained in:
@@ -47,6 +47,7 @@ def processImage(file, outputPath=None):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def rotateFromExifMetadata(image):
|
def rotateFromExifMetadata(image):
|
||||||
|
try:
|
||||||
for orientation in ExifTags.TAGS.keys():
|
for orientation in ExifTags.TAGS.keys():
|
||||||
if ExifTags.TAGS[orientation]=='Orientation':
|
if ExifTags.TAGS[orientation]=='Orientation':
|
||||||
break
|
break
|
||||||
@@ -60,6 +61,10 @@ def rotateFromExifMetadata(image):
|
|||||||
image=image.rotate(90, expand=True)
|
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):
|
def generateFilename(fileID, modifier, outputPath):
|
||||||
filename = "{}_{}.{}".format(fileID, modifier, OUTPUT_EXTENSION)
|
filename = "{}_{}.{}".format(fileID, modifier, OUTPUT_EXTENSION)
|
||||||
|
|||||||
Reference in New Issue
Block a user