diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 6c32b5ad427..0c21c9fab66 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -281,11 +281,7 @@ class Tc(NamedTuple): ) } - libtiffs = [False] - if Image.core.libtiff_support_custom_tags: - libtiffs.append(True) - - for libtiff in libtiffs: + for libtiff in [False, True]: TiffImagePlugin.WRITE_LIBTIFF = libtiff def check_tags( @@ -691,8 +687,7 @@ def test_exif_ifd(self, tmp_path: Path) -> None: im.save(outfile) with Image.open(outfile) as reloaded: - if Image.core.libtiff_support_custom_tags: - assert reloaded.tag_v2[34665] == 125456 + assert reloaded.tag_v2[34665] == 125456 def test_crashing_metadata(self, tmp_path: Path) -> None: # issue 1597 @@ -756,12 +751,7 @@ def check_write(libtiff: bool) -> None: with Image.open(out) as reloaded: assert icc_profile == reloaded.info["icc_profile"] - libtiffs = [] - if Image.core.libtiff_support_custom_tags: - libtiffs.append(True) - libtiffs.append(False) - - for libtiff in libtiffs: + for libtiff in [True, False]: check_write(libtiff) def test_multipage_compression(self) -> None: diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 10ac9ea3a2a..44103f37669 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -1823,9 +1823,6 @@ def _save(im, fp, filename): # Custom items are supported for int, float, unicode, string and byte # values. Other types and tuples require a tagtype. if tag not in TiffTags.LIBTIFF_CORE: - if not getattr(Image.core, "libtiff_support_custom_tags", False): - continue - if tag in ifd.tagtype: types[tag] = ifd.tagtype[tag] elif not (isinstance(value, (int, float, str, bytes))): diff --git a/src/_imaging.c b/src/_imaging.c index 520e5079346..8d9c2d257b3 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -4388,16 +4388,6 @@ setup_module(PyObject *m) { PyObject *v = PyUnicode_FromString(ImagingTiffVersion()); PyDict_SetItemString(d, "libtiff_version", v ? v : Py_None); Py_XDECREF(v); - - // Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7 - PyObject *support_custom_tags; -#if TIFFLIB_VERSION >= 20111221 && TIFFLIB_VERSION != 20120218 && \ - TIFFLIB_VERSION != 20120922 - support_custom_tags = Py_True; -#else - support_custom_tags = Py_False; -#endif - PyDict_SetItemString(d, "libtiff_support_custom_tags", support_custom_tags); } #endif