Skip to content

Commit

Permalink
Treat IFDs as LONG8
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Nov 4, 2024
1 parent a609816 commit 33fac14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/PIL/TiffTags.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ def lookup(tag: int, group: int | None = None) -> TagInfo:
33723: ("IptcNaaInfo", UNDEFINED, 1),
34377: ("PhotoshopInfo", BYTE, 0),
# FIXME add more tags here
34665: ("ExifIFD", LONG, 1),
34665: ("ExifIFD", LONG8, 1),
34675: ("ICCProfile", UNDEFINED, 1),
34853: ("GPSInfoIFD", LONG, 1),
34853: ("GPSInfoIFD", LONG8, 1),
36864: ("ExifVersion", UNDEFINED, 1),
37724: ("ImageSourceData", UNDEFINED, 1),
40965: ("InteroperabilityIFD", LONG, 1),
40965: ("InteroperabilityIFD", LONG8, 1),
41730: ("CFAPattern", UNDEFINED, 1),
# MPInfo
45056: ("MPFVersion", UNDEFINED, 1),
Expand Down Expand Up @@ -245,7 +245,7 @@ def lookup(tag: int, group: int | None = None) -> TagInfo:
34665: {
36864: ("ExifVersion", UNDEFINED, 1),
40960: ("FlashPixVersion", UNDEFINED, 1),
40965: ("InteroperabilityIFD", LONG, 1),
40965: ("InteroperabilityIFD", LONG8, 1),
41730: ("CFAPattern", UNDEFINED, 1),
},
# GPSInfoIFD
Expand Down
8 changes: 6 additions & 2 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
}
if (tag_type) {
int type_int = PyLong_AsLong(tag_type);
if (type_int >= TIFF_BYTE && type_int <= TIFF_DOUBLE) {
if (type_int >= TIFF_BYTE && type_int <= TIFF_LONG8) {
type = (TIFFDataType)type_int;
}
}
Expand Down Expand Up @@ -929,7 +929,7 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
);
} else if (type == TIFF_LONG) {
status = ImagingLibTiffSetField(
&encoder->state, (ttag_t)key_int, PyLong_AsLongLong(value)
&encoder->state, (ttag_t)key_int, (UINT32)PyLong_AsLong(value)
);
} else if (type == TIFF_SSHORT) {
status = ImagingLibTiffSetField(
Expand Down Expand Up @@ -959,6 +959,10 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
status = ImagingLibTiffSetField(
&encoder->state, (ttag_t)key_int, (FLOAT64)PyFloat_AsDouble(value)
);
} else if (type == TIFF_LONG8) {
status = ImagingLibTiffSetField(
&encoder->state, (ttag_t)key_int, PyLong_AsLongLong(value)
);
} else {
TRACE(
("Unhandled type for key %d : %s \n",
Expand Down

0 comments on commit 33fac14

Please sign in to comment.