Skip to content

Commit 99ee337

Browse files
authored
Merge pull request #8529 from radarhere/tiff_tags
2 parents dcd0479 + b6413cd commit 99ee337

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/PIL/TiffImagePlugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,9 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
19141914
if not getattr(Image.core, "libtiff_support_custom_tags", False):
19151915
continue
19161916

1917-
if tag in ifd.tagtype:
1917+
if tag in TiffTags.TAGS_V2_GROUPS:
1918+
types[tag] = TiffTags.LONG8
1919+
elif tag in ifd.tagtype:
19181920
types[tag] = ifd.tagtype[tag]
19191921
elif not (isinstance(value, (int, float, str, bytes))):
19201922
continue

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, (uint64_t)PyLong_AsLongLong(value)
965+
);
962966
} else {
963967
TRACE(
964968
("Unhandled type for key %d : %s \n",

0 commit comments

Comments
 (0)