mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
Added writing XMP bytes to JPEG
This commit is contained in:
parent
71876cfd2a
commit
2722cfd72b
|
@ -991,6 +991,13 @@ class TestFileJpeg:
|
||||||
else:
|
else:
|
||||||
assert im.getxmp() == {"xmpmeta": None}
|
assert im.getxmp() == {"xmpmeta": None}
|
||||||
|
|
||||||
|
def test_save_xmp(self, tmp_path: Path) -> None:
|
||||||
|
f = str(tmp_path / "temp.jpg")
|
||||||
|
hopper().save(f, xmp=b"XMP test")
|
||||||
|
|
||||||
|
with Image.open(f) as reloaded:
|
||||||
|
assert reloaded.info["xmp"] == b"XMP test"
|
||||||
|
|
||||||
@pytest.mark.timeout(timeout=1)
|
@pytest.mark.timeout(timeout=1)
|
||||||
def test_eof(self) -> None:
|
def test_eof(self) -> None:
|
||||||
# Even though this decoder never says that it is finished
|
# Even though this decoder never says that it is finished
|
||||||
|
|
|
@ -746,6 +746,11 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
|
||||||
|
|
||||||
extra = info.get("extra", b"")
|
extra = info.get("extra", b"")
|
||||||
|
|
||||||
|
xmp = info.get("xmp")
|
||||||
|
if xmp:
|
||||||
|
size = o16(31 + len(xmp))
|
||||||
|
extra += b"\xFF\xE1" + size + b"http://ns.adobe.com/xap/1.0/\x00" + xmp
|
||||||
|
|
||||||
MAX_BYTES_IN_MARKER = 65533
|
MAX_BYTES_IN_MARKER = 65533
|
||||||
icc_profile = info.get("icc_profile")
|
icc_profile = info.get("icc_profile")
|
||||||
if icc_profile:
|
if icc_profile:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user