Fix meta error
This commit is contained in:
parent
149890f2eb
commit
a6c932b961
1 changed files with 15 additions and 10 deletions
|
|
@ -39,13 +39,18 @@ def thumbnail(image, name, args):
|
||||||
try:
|
try:
|
||||||
size = (450, 450)
|
size = (450, 450)
|
||||||
im = Image.open(image)
|
im = Image.open(image)
|
||||||
|
exif = None
|
||||||
|
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
|
||||||
exif = im._getexif()
|
exif = im._getexif()
|
||||||
|
except (AttributeError, KeyError, IndexError):
|
||||||
|
pass
|
||||||
|
|
||||||
im.thumbnail(size)
|
im.thumbnail(size)
|
||||||
|
|
||||||
|
if exif is not None:
|
||||||
if exif[orientation] == 3:
|
if exif[orientation] == 3:
|
||||||
im = im.rotate(180, expand=True)
|
im = im.rotate(180, expand=True)
|
||||||
elif exif[orientation] == 6:
|
elif exif[orientation] == 6:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue