Skip to content

Commit 9c9449a

Browse files
committed
Removed support for LibTIFF < 4
1 parent a7e00fb commit 9c9449a

File tree

5 files changed

+13
-62
lines changed

5 files changed

+13
-62
lines changed

Tests/test_file_libtiff.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,7 @@ def test_additional_metadata(
256256

257257
im.save(out, tiffinfo=new_ifd)
258258

259-
@pytest.mark.parametrize(
260-
"libtiff",
261-
(
262-
pytest.param(
263-
True,
264-
marks=pytest.mark.skipif(
265-
not getattr(Image.core, "libtiff_support_custom_tags", False),
266-
reason="Custom tags not supported by older libtiff",
267-
),
268-
),
269-
False,
270-
),
271-
)
259+
@pytest.mark.parametrize("libtiff", (True, False))
272260
def test_custom_metadata(
273261
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path, libtiff: bool
274262
) -> None:
@@ -724,8 +712,7 @@ def test_exif_ifd(self) -> None:
724712

725713
with Image.open(out) as reloaded:
726714
assert isinstance(reloaded, TiffImagePlugin.TiffImageFile)
727-
if Image.core.libtiff_support_custom_tags:
728-
assert reloaded.tag_v2[34665] == 125456
715+
assert reloaded.tag_v2[34665] == 125456
729716

730717
def test_crashing_metadata(
731718
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
@@ -777,19 +764,7 @@ def test_read_icc(self, monkeypatch: pytest.MonkeyPatch) -> None:
777764
assert icc_libtiff is not None
778765
assert icc == icc_libtiff
779766

780-
@pytest.mark.parametrize(
781-
"libtiff",
782-
(
783-
pytest.param(
784-
True,
785-
marks=pytest.mark.skipif(
786-
not getattr(Image.core, "libtiff_support_custom_tags", False),
787-
reason="Custom tags not supported by older libtiff",
788-
),
789-
),
790-
False,
791-
),
792-
)
767+
@pytest.mark.parametrize("libtiff", (True, False))
793768
def test_write_icc(
794769
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path, libtiff: bool
795770
) -> None:

docs/deprecations.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,6 @@ The use in :py:mod:`.ImageCms` of input modes and output modes that are not Pill
7777
image modes has been deprecated. Defaulting to "L" or "1" if the mode cannot be mapped
7878
is also deprecated.
7979

80-
Support for LibTIFF earlier than 4
81-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82-
83-
.. deprecated:: 10.4.0
84-
85-
Support for LibTIFF earlier than version 4 has been deprecated.
86-
Upgrade to a newer version of LibTIFF instead.
87-
8880
ImageDraw.getdraw hints parameter
8981
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9082

@@ -194,6 +186,15 @@ BGR;15, BGR 16 and BGR;24
194186

195187
The experimental BGR;15, BGR;16 and BGR;24 modes have been removed.
196188

189+
Support for LibTIFF earlier than 4
190+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
191+
192+
.. deprecated:: 10.4.0
193+
.. versionremoved:: 12.0.0
194+
195+
Support for LibTIFF earlier than version 4 has been removed.
196+
Upgrade to a newer version of LibTIFF instead.
197+
197198
Image isImageType()
198199
^^^^^^^^^^^^^^^^^^^
199200

src/PIL/TiffImagePlugin.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
from ._binary import i16be as i16
5757
from ._binary import i32be as i32
5858
from ._binary import o8
59-
from ._deprecate import deprecate
6059
from ._typing import StrOrBytesPath
6160
from ._util import DeferredError, is_path
6261
from .TiffTags import TYPES
@@ -284,9 +283,6 @@
284283
b"II\x2b\x00", # BigTIFF with little-endian byte order
285284
]
286285

287-
if not getattr(Image.core, "libtiff_support_custom_tags", True):
288-
deprecate("Support for LibTIFF earlier than version 4", 12)
289-
290286

291287
def _accept(prefix: bytes) -> bool:
292288
return prefix.startswith(tuple(PREFIXES))
@@ -1934,9 +1930,6 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
19341930
# Custom items are supported for int, float, unicode, string and byte
19351931
# values. Other types and tuples require a tagtype.
19361932
if tag not in TiffTags.LIBTIFF_CORE:
1937-
if not getattr(Image.core, "libtiff_support_custom_tags", False):
1938-
continue
1939-
19401933
if tag in TiffTags.TAGS_V2_GROUPS:
19411934
types[tag] = TiffTags.LONG8
19421935
elif tag in ifd.tagtype:

src/_imaging.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4352,16 +4352,6 @@ setup_module(PyObject *m) {
43524352
PyObject *v = PyUnicode_FromString(ImagingTiffVersion());
43534353
PyDict_SetItemString(d, "libtiff_version", v ? v : Py_None);
43544354
Py_XDECREF(v);
4355-
4356-
// Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7
4357-
PyObject *support_custom_tags;
4358-
#if TIFFLIB_VERSION >= 20111221 && TIFFLIB_VERSION != 20120218 && \
4359-
TIFFLIB_VERSION != 20120922
4360-
support_custom_tags = Py_True;
4361-
#else
4362-
support_custom_tags = Py_False;
4363-
#endif
4364-
PyDict_SetItemString(d, "libtiff_support_custom_tags", support_custom_tags);
43654355
}
43664356
#endif
43674357

src/libImaging/TiffDecode.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ ImagingLibTiffMergeFieldInfo(
884884
// Refer to libtiff docs (http://www.simplesystems.org/libtiff/addingtags.html)
885885
TIFFSTATE *clientstate = (TIFFSTATE *)state->context;
886886
uint32_t n;
887-
int status = 0;
888887

889888
// custom fields added with ImagingLibTiffMergeFieldInfo are only used for
890889
// decoding, ignore readcount;
@@ -907,14 +906,7 @@ ImagingLibTiffMergeFieldInfo(
907906

908907
n = sizeof(info) / sizeof(info[0]);
909908

910-
// Test for libtiff 4.0 or later, excluding libtiff 3.9.6 and 3.9.7
911-
#if TIFFLIB_VERSION >= 20111221 && TIFFLIB_VERSION != 20120218 && \
912-
TIFFLIB_VERSION != 20120922
913-
status = TIFFMergeFieldInfo(clientstate->tiff, info, n);
914-
#else
915-
TIFFMergeFieldInfo(clientstate->tiff, info, n);
916-
#endif
917-
return status;
909+
return TIFFMergeFieldInfo(clientstate->tiff, info, n);
918910
}
919911

920912
int

0 commit comments

Comments
 (0)