mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-27 16:33:15 +03:00
Fixed writing int as UNDEFINED tag
This commit is contained in:
parent
98b2a568b9
commit
ad0e9dbaaf
|
@ -216,6 +216,22 @@ def test_writing_other_types_to_bytes(value, tmp_path):
|
||||||
assert reloaded.tag_v2[700] == b"\x01"
|
assert reloaded.tag_v2[700] == b"\x01"
|
||||||
|
|
||||||
|
|
||||||
|
def test_writing_other_types_to_undefined(tmp_path):
|
||||||
|
im = hopper()
|
||||||
|
info = TiffImagePlugin.ImageFileDirectory_v2()
|
||||||
|
|
||||||
|
tag = TiffTags.TAGS_V2[33723]
|
||||||
|
assert tag.type == TiffTags.UNDEFINED
|
||||||
|
|
||||||
|
info[33723] = 1
|
||||||
|
|
||||||
|
out = str(tmp_path / "temp.tiff")
|
||||||
|
im.save(out, tiffinfo=info)
|
||||||
|
|
||||||
|
with Image.open(out) as reloaded:
|
||||||
|
assert reloaded.tag_v2[33723] == b"1"
|
||||||
|
|
||||||
|
|
||||||
def test_undefined_zero(tmp_path):
|
def test_undefined_zero(tmp_path):
|
||||||
# Check that the tag has not been changed since this test was created
|
# Check that the tag has not been changed since this test was created
|
||||||
tag = TiffTags.TAGS_V2[45059]
|
tag = TiffTags.TAGS_V2[45059]
|
||||||
|
|
|
@ -764,6 +764,8 @@ class ImageFileDirectory_v2(MutableMapping):
|
||||||
|
|
||||||
@_register_writer(7)
|
@_register_writer(7)
|
||||||
def write_undefined(self, value):
|
def write_undefined(self, value):
|
||||||
|
if isinstance(value, int):
|
||||||
|
value = str(value).encode("ascii", "replace")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@_register_loader(10, 8)
|
@_register_loader(10, 8)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user