mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Allow writing IFDRational to BYTE tag
This commit is contained in:
parent
145b80be56
commit
e48aead015
|
@ -202,14 +202,15 @@ def test_writing_other_types_to_ascii(value, expected, tmp_path):
|
|||
assert reloaded.tag_v2[271] == expected
|
||||
|
||||
|
||||
def test_writing_int_to_bytes(tmp_path):
|
||||
@pytest.mark.parametrize("value", (1, IFDRational(1)))
|
||||
def test_writing_other_types_to_bytes(value, tmp_path):
|
||||
im = hopper()
|
||||
info = TiffImagePlugin.ImageFileDirectory_v2()
|
||||
|
||||
tag = TiffTags.TAGS_V2[700]
|
||||
assert tag.type == TiffTags.BYTE
|
||||
|
||||
info[700] = 1
|
||||
info[700] = value
|
||||
|
||||
out = str(tmp_path / "temp.tiff")
|
||||
im.save(out, tiffinfo=info)
|
||||
|
|
|
@ -722,6 +722,8 @@ class ImageFileDirectory_v2(MutableMapping):
|
|||
|
||||
@_register_writer(1) # Basic type, except for the legacy API.
|
||||
def write_byte(self, data):
|
||||
if isinstance(data, IFDRational):
|
||||
data = int(data)
|
||||
if isinstance(data, int):
|
||||
data = bytes((data,))
|
||||
return data
|
||||
|
|
Loading…
Reference in New Issue
Block a user