mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Fixed writing int as BYTE tag
This commit is contained in:
parent
a7008f9f2f
commit
70cc8a5741
|
@ -201,6 +201,22 @@ def test_writing_bytes_to_ascii(tmp_path):
|
||||||
assert reloaded.tag_v2[271] == "test"
|
assert reloaded.tag_v2[271] == "test"
|
||||||
|
|
||||||
|
|
||||||
|
def test_writing_int_to_bytes(tmp_path):
|
||||||
|
im = hopper()
|
||||||
|
info = TiffImagePlugin.ImageFileDirectory_v2()
|
||||||
|
|
||||||
|
tag = TiffTags.TAGS_V2[700]
|
||||||
|
assert tag.type == TiffTags.BYTE
|
||||||
|
|
||||||
|
info[700] = 1
|
||||||
|
|
||||||
|
out = str(tmp_path / "temp.tiff")
|
||||||
|
im.save(out, tiffinfo=info)
|
||||||
|
|
||||||
|
with Image.open(out) as reloaded:
|
||||||
|
assert reloaded.tag_v2[700] == b"\x01"
|
||||||
|
|
||||||
|
|
||||||
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]
|
||||||
|
|
|
@ -719,6 +719,8 @@ class ImageFileDirectory_v2(MutableMapping):
|
||||||
|
|
||||||
@_register_writer(1) # Basic type, except for the legacy API.
|
@_register_writer(1) # Basic type, except for the legacy API.
|
||||||
def write_byte(self, data):
|
def write_byte(self, data):
|
||||||
|
if isinstance(data, int):
|
||||||
|
data = bytes((data,))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@_register_loader(2, 1)
|
@_register_loader(2, 1)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user