Skip to content

Commit 33fac14

Browse files
committed
Treat IFDs as LONG8
1 parent a609816 commit 33fac14

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/PIL/TiffTags.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ def lookup(tag: int, group: int | None = None) -> TagInfo:
207207
33723: ("IptcNaaInfo", UNDEFINED, 1),
208208
34377: ("PhotoshopInfo", BYTE, 0),
209209
# FIXME add more tags here
210-
34665: ("ExifIFD", LONG, 1),
210+
34665: ("ExifIFD", LONG8, 1),
211211
34675: ("ICCProfile", UNDEFINED, 1),
212-
34853: ("GPSInfoIFD", LONG, 1),
212+
34853: ("GPSInfoIFD", LONG8, 1),
213213
36864: ("ExifVersion", UNDEFINED, 1),
214214
37724: ("ImageSourceData", UNDEFINED, 1),
215-
40965: ("InteroperabilityIFD", LONG, 1),
215+
40965: ("InteroperabilityIFD", LONG8, 1),
216216
41730: ("CFAPattern", UNDEFINED, 1),
217217
# MPInfo
218218
45056: ("MPFVersion", UNDEFINED, 1),
@@ -245,7 +245,7 @@ def lookup(tag: int, group: int | None = None) -> TagInfo:
245245
34665: {
246246
36864: ("ExifVersion", UNDEFINED, 1),
247247
40960: ("FlashPixVersion", UNDEFINED, 1),
248-
40965: ("InteroperabilityIFD", LONG, 1),
248+
40965: ("InteroperabilityIFD", LONG8, 1),
249249
41730: ("CFAPattern", UNDEFINED, 1),
250250
},
251251
# GPSInfoIFD

src/encode.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
736736
}
737737
if (tag_type) {
738738
int type_int = PyLong_AsLong(tag_type);
739-
if (type_int >= TIFF_BYTE && type_int <= TIFF_DOUBLE) {
739+
if (type_int >= TIFF_BYTE && type_int <= TIFF_LONG8) {
740740
type = (TIFFDataType)type_int;
741741
}
742742
}
@@ -929,7 +929,7 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
929929
);
930930
} else if (type == TIFF_LONG) {
931931
status = ImagingLibTiffSetField(
932-
&encoder->state, (ttag_t)key_int, PyLong_AsLongLong(value)
932+
&encoder->state, (ttag_t)key_int, (UINT32)PyLong_AsLong(value)
933933
);
934934
} else if (type == TIFF_SSHORT) {
935935
status = ImagingLibTiffSetField(
@@ -959,6 +959,10 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
959959
status = ImagingLibTiffSetField(
960960
&encoder->state, (ttag_t)key_int, (FLOAT64)PyFloat_AsDouble(value)
961961
);
962+
} else if (type == TIFF_LONG8) {
963+
status = ImagingLibTiffSetField(
964+
&encoder->state, (ttag_t)key_int, PyLong_AsLongLong(value)
965+
);
962966
} else {
963967
TRACE(
964968
("Unhandled type for key %d : %s \n",

0 commit comments

Comments
 (0)