Skip to content

Commit

Permalink
Do not save orientation in EXIF data
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 7, 2024
1 parent 003f0a3 commit 1c5b438
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,16 @@ 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
exif = exif.tobytes()
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"))

Expand Down
15 changes: 0 additions & 15 deletions src/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c5b438

Please sign in to comment.