Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ def test_subifd(self, tmp_path: Path) -> None:
# Should not segfault
im.save(outfile)

def test_whitepoint_tag(
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", True)

out = tmp_path / "temp.tif"
hopper().save(out, tiffinfo={318: (0.3127, 0.3289)})

with Image.open(out) as reloaded:
assert isinstance(reloaded, TiffImagePlugin.TiffImageFile)
assert reloaded.tag_v2[318] == pytest.approx((0.3127, 0.3289))

def test_xmlpacket_tag(
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
Expand Down
12 changes: 12 additions & 0 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,18 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
);
free(av);
}
} else if (type == TIFF_RATIONAL) {
FLOAT32 *av;
/* malloc check ok, calloc checks for overflow */
av = calloc(len, sizeof(FLOAT32));
if (av) {
for (i = 0; i < len; i++) {
av[i] = (FLOAT32)PyFloat_AsDouble(PyTuple_GetItem(value, i));
}
status =
ImagingLibTiffSetField(&encoder->state, (ttag_t)key_int, av);
free(av);
}
}
} else {
if (type == TIFF_SHORT) {
Expand Down
Loading