mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Save xmp from info
This commit is contained in:
parent
c056406f21
commit
be34a7da4b
|
@ -995,11 +995,13 @@ class TestFileJpeg:
|
||||||
f = str(tmp_path / "temp.jpg")
|
f = str(tmp_path / "temp.jpg")
|
||||||
im = hopper()
|
im = hopper()
|
||||||
im.save(f, xmp=b"XMP test")
|
im.save(f, xmp=b"XMP test")
|
||||||
|
|
||||||
with Image.open(f) as reloaded:
|
with Image.open(f) as reloaded:
|
||||||
assert reloaded.info["xmp"] == b"XMP test"
|
assert reloaded.info["xmp"] == b"XMP test"
|
||||||
|
|
||||||
im.save(f, xmp=b"1" * 65504)
|
im.info["xmp"] = b"1" * 65504
|
||||||
|
im.save(f)
|
||||||
|
with Image.open(f) as reloaded:
|
||||||
|
assert reloaded.info["xmp"] == b"1" * 65504
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
im.save(f, xmp=b"1" * 65505)
|
im.save(f, xmp=b"1" * 65505)
|
||||||
|
|
|
@ -747,7 +747,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
extra = info.get("extra", b"")
|
extra = info.get("extra", b"")
|
||||||
|
|
||||||
MAX_BYTES_IN_MARKER = 65533
|
MAX_BYTES_IN_MARKER = 65533
|
||||||
xmp = info.get("xmp")
|
xmp = info.get("xmp", im.info.get("xmp"))
|
||||||
if xmp:
|
if xmp:
|
||||||
overhead_len = 29 # b"http://ns.adobe.com/xap/1.0/\x00"
|
overhead_len = 29 # b"http://ns.adobe.com/xap/1.0/\x00"
|
||||||
max_data_bytes_in_marker = MAX_BYTES_IN_MARKER - overhead_len
|
max_data_bytes_in_marker = MAX_BYTES_IN_MARKER - overhead_len
|
||||||
|
|
Loading…
Reference in New Issue
Block a user