mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-10-28 14:41:07 +03:00
Support writing SIGNED_RATIONAL tag types
This commit is contained in:
parent
ddd4f00720
commit
82cdaa456c
|
|
@ -355,12 +355,15 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
# Should not segfault
|
# Should not segfault
|
||||||
im.save(outfile)
|
im.save(outfile)
|
||||||
|
|
||||||
def test_ifd(self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
@pytest.mark.parametrize("tagtype", (TiffTags.SIGNED_RATIONAL, TiffTags.IFD))
|
||||||
|
def test_tag_type(
|
||||||
|
self, tagtype: int, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||||
|
) -> None:
|
||||||
monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", True)
|
monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", True)
|
||||||
|
|
||||||
ifd = TiffImagePlugin.ImageFileDirectory_v2()
|
ifd = TiffImagePlugin.ImageFileDirectory_v2()
|
||||||
ifd[37000] = 100
|
ifd[37000] = 100
|
||||||
ifd.tagtype[37000] = TiffTags.IFD
|
ifd.tagtype[37000] = tagtype
|
||||||
|
|
||||||
out = tmp_path / "temp.tif"
|
out = tmp_path / "temp.tif"
|
||||||
im = Image.new("L", (1, 1))
|
im = Image.new("L", (1, 1))
|
||||||
|
|
|
||||||
|
|
@ -990,10 +990,6 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state, (ttag_t)key_int, (FLOAT32)PyFloat_AsDouble(value)
|
&encoder->state, (ttag_t)key_int, (FLOAT32)PyFloat_AsDouble(value)
|
||||||
);
|
);
|
||||||
} else if (type == TIFF_DOUBLE) {
|
|
||||||
status = ImagingLibTiffSetField(
|
|
||||||
&encoder->state, (ttag_t)key_int, (FLOAT64)PyFloat_AsDouble(value)
|
|
||||||
);
|
|
||||||
} else if (type == TIFF_SBYTE) {
|
} else if (type == TIFF_SBYTE) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state, (ttag_t)key_int, (INT8)PyLong_AsLong(value)
|
&encoder->state, (ttag_t)key_int, (INT8)PyLong_AsLong(value)
|
||||||
|
|
@ -1002,7 +998,8 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state, (ttag_t)key_int, PyBytes_AsString(value)
|
&encoder->state, (ttag_t)key_int, PyBytes_AsString(value)
|
||||||
);
|
);
|
||||||
} else if (type == TIFF_RATIONAL) {
|
} else if (type == TIFF_DOUBLE || type == TIFF_SRATIONAL ||
|
||||||
|
type == TIFF_RATIONAL) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state, (ttag_t)key_int, (FLOAT64)PyFloat_AsDouble(value)
|
&encoder->state, (ttag_t)key_int, (FLOAT64)PyFloat_AsDouble(value)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user