From 970db0dc05284e0af48f4fb6b6ee4409b119e65d Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Fri, 25 Feb 2022 07:47:34 +0100 Subject: [PATCH] Fix AttributeError on EXIF load --- photologue/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/photologue/models.py b/photologue/models.py index ede27c3..fab1f3c 100644 --- a/photologue/models.py +++ b/photologue/models.py @@ -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)