Skip to content

Commit

Permalink
Do not save XMP and EXIF data from info dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 7, 2024
1 parent 1c5b438 commit fbc9010
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
29 changes: 1 addition & 28 deletions Tests/test_file_avif.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,8 @@ def test_exif(self) -> None:
exif = im.getexif()
assert exif[274] == 3

def test_exif_save_default(self, tmp_path: Path) -> None:
with Image.open("Tests/images/avif/exif.avif") as im:
test_file = str(tmp_path / "temp.avif")
im.save(test_file)

with Image.open(test_file) as reloaded:
exif = reloaded.getexif()
assert exif[274] == 1

@pytest.mark.parametrize("bytes", [True, False])
def test_exif_save_argument(self, tmp_path: Path, bytes: bool) -> None:
def test_exif_save(self, tmp_path: Path, bytes: bool) -> None:
exif = Image.Exif()
exif[274] = 1
exif_data = exif.tobytes()
Expand All @@ -362,24 +353,6 @@ def test_xmp(self) -> None:
assert_xmp_orientation(xmp, 3)

def test_xmp_save(self, tmp_path: Path) -> None:
with Image.open("Tests/images/avif/xmp_tags_orientation.avif") as im:
test_file = str(tmp_path / "temp.avif")
im.save(test_file)

with Image.open(test_file) as reloaded:
xmp = reloaded.info["xmp"]
assert_xmp_orientation(xmp, 3)

def test_xmp_save_from_png(self, tmp_path: Path) -> None:
with Image.open("Tests/images/xmp_tags_orientation.png") as im:
test_file = str(tmp_path / "temp.avif")
im.save(test_file)

with Image.open(test_file) as reloaded:
xmp = reloaded.info["xmp"]
assert_xmp_orientation(xmp, 3)

def test_xmp_save_argument(self, tmp_path: Path) -> None:
xmp_arg = "\n".join(
[
'<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>',
Expand Down
4 changes: 2 additions & 2 deletions src/PIL/AvifImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def _save(
autotiling = bool(info.get("autotiling", tile_rows_log2 == tile_cols_log2 == 0))

icc_profile = info.get("icc_profile", im.info.get("icc_profile"))
exif = info.get("exif", im.info.get("exif"))
exif = info.get("exif")
if exif:
if isinstance(exif, Image.Exif):
exif_data = exif
Expand All @@ -180,7 +180,7 @@ def _save(
else:
exif_orientation = 1

xmp = info.get("xmp", im.info.get("xmp") or im.info.get("XML:com.adobe.xmp"))
xmp = info.get("xmp")

if isinstance(xmp, str):
xmp = xmp.encode("utf-8")
Expand Down

0 comments on commit fbc9010

Please sign in to comment.