From fbc901060814d53757b73c4e4409358a7cff908d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 7 Dec 2024 17:05:08 +1100 Subject: [PATCH] Do not save XMP and EXIF data from info dictionary --- Tests/test_file_avif.py | 29 +---------------------------- src/PIL/AvifImagePlugin.py | 4 ++-- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/Tests/test_file_avif.py b/Tests/test_file_avif.py index 003d292beab..cc9f0a3a088 100644 --- a/Tests/test_file_avif.py +++ b/Tests/test_file_avif.py @@ -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() @@ -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( [ '', diff --git a/src/PIL/AvifImagePlugin.py b/src/PIL/AvifImagePlugin.py index 17a145867f3..2b205c4a53a 100644 --- a/src/PIL/AvifImagePlugin.py +++ b/src/PIL/AvifImagePlugin.py @@ -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 @@ -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")