From 1c5b438921772bde76a4b96e5f5354119cca7390 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 7 Dec 2024 16:06:13 +1100 Subject: [PATCH] Do not save orientation in EXIF data --- src/PIL/AvifImagePlugin.py | 5 +++-- src/_avif.c | 15 --------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/PIL/AvifImagePlugin.py b/src/PIL/AvifImagePlugin.py index d9d2850037e..17a145867f3 100644 --- a/src/PIL/AvifImagePlugin.py +++ b/src/PIL/AvifImagePlugin.py @@ -169,7 +169,6 @@ def _save( icc_profile = info.get("icc_profile", im.info.get("icc_profile")) exif = info.get("exif", im.info.get("exif")) - exif_orientation = 0 if exif: if isinstance(exif, Image.Exif): exif_data = exif @@ -177,7 +176,9 @@ def _save( else: exif_data = Image.Exif() exif_data.load(exif) - exif_orientation = exif_data.get(ExifTags.Base.Orientation, 0) + exif_orientation = exif_data.pop(ExifTags.Base.Orientation, 1) + else: + exif_orientation = 1 xmp = info.get("xmp", im.info.get("xmp") or im.info.get("XML:com.adobe.xmp")) diff --git a/src/_avif.c b/src/_avif.c index 1d4bb74010e..ac2ec283bc1 100644 --- a/src/_avif.c +++ b/src/_avif.c @@ -170,22 +170,7 @@ exif_orientation_to_irot_imir(avifImage *image, int orientation) { image->imir.mode = 0; // ignored #endif return; - default: // reserved - break; } - - // The orientation tag is not mandatory (only recommended) according to JEITA - // CP-3451C section 4.6.8.A. The default value is 1 if the orientation tag is - // missing, meaning: - // The 0th row is at the visual top of the image, and the 0th column is the visual - // left-hand side. - image->transformFlags = otherFlags; - image->irot.angle = 0; // ignored -#if AVIF_VERSION_MAJOR >= 1 - image->imir.axis = 0; // ignored -#else - image->imir.mode = 0; // ignored -#endif } static int