Removed forcing of BYTE to ASCII

This commit is contained in:
Andrew Murray 2020-05-03 19:41:38 +10:00
parent 7ecb5aaf7e
commit 859b27572b
2 changed files with 17 additions and 3 deletions

View File

@ -299,7 +299,11 @@ class TestFileLibTiff(LibTiffTestCase):
)
continue
if libtiff and isinstance(value, bytes):
if (
libtiff
and isinstance(value, bytes)
and isinstance(tiffinfo, dict)
):
value = value.decode()
assert reloaded_value == value
@ -322,6 +326,17 @@ class TestFileLibTiff(LibTiffTestCase):
)
TiffImagePlugin.WRITE_LIBTIFF = False
def test_xmlpacket_tag(self, tmp_path):
TiffImagePlugin.WRITE_LIBTIFF = True
out = str(tmp_path / "temp.tif")
hopper().save(out, tiffinfo={700: b"xmlpacket tag"})
TiffImagePlugin.WRITE_LIBTIFF = False
with Image.open(out) as reloaded:
if 700 in reloaded.tag_v2:
assert reloaded.tag_v2[700] == b"xmlpacket tag"
def test_int_dpi(self, tmp_path):
# issue #1765
im = hopper("RGB")

View File

@ -761,8 +761,7 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
}
}
if (PyBytes_Check(value) &&
(type == TIFF_BYTE || type == TIFF_UNDEFINED)) {
if (PyBytes_Check(value) && type == TIFF_UNDEFINED) {
// For backwards compatibility
type = TIFF_ASCII;
}