avoid uselsse exif() calls

This commit is contained in:
krek0 2026-05-07 14:04:23 +02:00
parent 96afb9cc0b
commit 1b6eb7d4a0

View file

@ -415,14 +415,15 @@ class ImageModel(models.Model):
# Save the original format # Save the original format
im_format = im.format im_format = im.format
# Rotate if found & necessary # Rotate if found & necessary
exif = self.exif()
if ( if (
"Image Orientation" in self.exif() "Image Orientation" in exif
and self.exif().get("Image Orientation").values[0] and exif.get("Image Orientation").values[0]
in IMAGE_EXIF_ORIENTATION_MAP in IMAGE_EXIF_ORIENTATION_MAP
): ):
im = im.transpose( im = im.transpose(
IMAGE_EXIF_ORIENTATION_MAP[ IMAGE_EXIF_ORIENTATION_MAP[
self.exif().get("Image Orientation").values[0] exif.get("Image Orientation").values[0]
] ]
) )
# Resize/crop image # Resize/crop image