Skip to content

Commit

Permalink
Do not save XMP from info
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Oct 18, 2024
1 parent d59b169 commit 98f975d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Tests/test_file_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,13 @@ def test_save_xmp(self, tmp_path: Path) -> None:
with Image.open(f) as reloaded:
assert reloaded.info["xmp"] == b"XMP test"

im.info["xmp"] = b"1" * 65504
im.save(f)
# Check that XMP is not saved from image info
reloaded.save(f)

with Image.open(f) as reloaded:
assert "xmp" not in reloaded.info

im.save(f, xmp=b"1" * 65504)
with Image.open(f) as reloaded:
assert reloaded.info["xmp"] == b"1" * 65504

Expand Down
2 changes: 1 addition & 1 deletion src/PIL/JpegImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ def validate_qtables(
extra = info.get("extra", b"")

MAX_BYTES_IN_MARKER = 65533
xmp = info.get("xmp", im.info.get("xmp"))
xmp = info.get("xmp")
if xmp:
overhead_len = 29 # b"http://ns.adobe.com/xap/1.0/\x00"
max_data_bytes_in_marker = MAX_BYTES_IN_MARKER - overhead_len
Expand Down

0 comments on commit 98f975d

Please sign in to comment.