Use Pillow's non-experimental getexif (#19098)

It has been available since Pillow 6, and Synapse is now pinned on
Pillow >=10.0.1.

Found this while looking at Debian-shipped dependencies, and figured
this may as well be updated.
This commit is contained in:
Andrew Ferrazzutti
2025-10-28 14:11:45 -04:00
committed by GitHub
parent 086b887f29
commit a07dd43ac4
2 changed files with 2 additions and 10 deletions

1
changelog.d/19098.misc Normal file
View File

@@ -0,0 +1 @@
Use Pillow's `Image.getexif` method instead of the experimental `Image._getexif`.

View File

@@ -97,16 +97,7 @@ class Thumbnailer:
self.transpose_method = None
try:
# We don't use ImageOps.exif_transpose since it crashes with big EXIF
#
# Ignore safety: Pillow seems to acknowledge that this method is
# "private, experimental, but generally widely used". Pillow 6
# includes a public getexif() method (no underscore) that we might
# consider using instead when we can bump that dependency.
#
# At the time of writing, Debian buster (currently oldstable)
# provides version 5.4.1. It's expected to EOL in mid-2022, see
# https://wiki.debian.org/DebianReleases#Production_Releases
image_exif = self.image._getexif() # type: ignore
image_exif = self.image.getexif()
if image_exif is not None:
image_orientation = image_exif.get(EXIF_ORIENTATION_TAG)
assert type(image_orientation) is int # noqa: E721