mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-10-29 15:07:44 +03:00
Support writing IFD tag types
This commit is contained in:
parent
b04d8792f5
commit
ddd4f00720
|
|
@ -355,6 +355,20 @@ 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:
|
||||||
|
monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", True)
|
||||||
|
|
||||||
|
ifd = TiffImagePlugin.ImageFileDirectory_v2()
|
||||||
|
ifd[37000] = 100
|
||||||
|
ifd.tagtype[37000] = TiffTags.IFD
|
||||||
|
|
||||||
|
out = tmp_path / "temp.tif"
|
||||||
|
im = Image.new("L", (1, 1))
|
||||||
|
im.save(out, tiffinfo=ifd)
|
||||||
|
|
||||||
|
with Image.open(out) as reloaded:
|
||||||
|
assert reloaded.tag_v2[37000] == 100
|
||||||
|
|
||||||
def test_inknames_tag(
|
def test_inknames_tag(
|
||||||
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
|
|
@ -974,7 +974,7 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state, (ttag_t)key_int, (UINT16)PyLong_AsLong(value)
|
&encoder->state, (ttag_t)key_int, (UINT16)PyLong_AsLong(value)
|
||||||
);
|
);
|
||||||
} else if (type == TIFF_LONG) {
|
} else if (type == TIFF_LONG || type == TIFF_IFD) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state, (ttag_t)key_int, (UINT32)PyLong_AsLong(value)
|
&encoder->state, (ttag_t)key_int, (UINT32)PyLong_AsLong(value)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user