mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-15 09:44:46 +03:00
Merge 7afbafd1e2
into 092d4422d5
This commit is contained in:
commit
339898dc30
|
@ -355,6 +355,18 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
# Should not segfault
|
# Should not segfault
|
||||||
im.save(outfile)
|
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(
|
def test_xmlpacket_tag(
|
||||||
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
12
src/encode.c
12
src/encode.c
|
@ -922,6 +922,18 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||||
);
|
);
|
||||||
free(av);
|
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 {
|
} else {
|
||||||
if (type == TIFF_SHORT) {
|
if (type == TIFF_SHORT) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user