Fix AttributeError on EXIF load

This commit is contained in:
Alexandre Iooss 2022-02-25 07:47:34 +01:00
parent 167c9cb45b
commit 970db0dc05

View file

@ -290,6 +290,10 @@ class ImageModel(models.Model):
setattr(self, name, result)
return result
else:
# When this attribute error is raised, it's usually because
# something tried to access a missing attribute on the photo.
# 99% of the time is due to a typo in the attribute name we are
# trying to access.
raise AttributeError
def size_exists(self, photosize):
@ -354,7 +358,7 @@ class ImageModel(models.Model):
if 'Image Orientation' in self.exif() and \
self.exif().get('Image Orientation').values[0] in IMAGE_EXIF_ORIENTATION_MAP:
im = im.transpose(
IMAGE_EXIF_ORIENTATION_MAP[self.EXIF().get('Image Orientation').values[0]])
IMAGE_EXIF_ORIENTATION_MAP[self.exif().get('Image Orientation').values[0]])
# Resize/crop image
if (im.size != photosize.size and photosize.size != (0, 0)) or recreate:
im = self.resize_image(im, photosize)