Skip to content

Commit

Permalink
Removed support for libtiff < 4
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Apr 20, 2024
1 parent f8160b8 commit babfc9b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
16 changes: 3 additions & 13 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))):
Expand Down
10 changes: 0 additions & 10 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit babfc9b

Please sign in to comment.