mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-10-28 22:47:41 +03:00
Support writing InkNames
This commit is contained in:
parent
76f04b46c5
commit
b04d8792f5
|
|
@ -355,6 +355,18 @@ class TestFileLibTiff(LibTiffTestCase):
|
||||||
# Should not segfault
|
# Should not segfault
|
||||||
im.save(outfile)
|
im.save(outfile)
|
||||||
|
|
||||||
|
def test_inknames_tag(
|
||||||
|
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||||
|
) -> None:
|
||||||
|
monkeypatch.setattr(TiffImagePlugin, "WRITE_LIBTIFF", True)
|
||||||
|
|
||||||
|
out = tmp_path / "temp.tif"
|
||||||
|
hopper("L").save(out, tiffinfo={333: "name\x00"})
|
||||||
|
|
||||||
|
with Image.open(out) as reloaded:
|
||||||
|
assert isinstance(reloaded, TiffImagePlugin.TiffImageFile)
|
||||||
|
assert reloaded.tag_v2[333] in ("name", "name\x00")
|
||||||
|
|
||||||
def test_whitepoint_tag(
|
def test_whitepoint_tag(
|
||||||
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
||||||
|
|
@ -558,7 +558,6 @@ LIBTIFF_CORE = {
|
||||||
LIBTIFF_CORE.remove(255) # We don't have support for subfiletypes
|
LIBTIFF_CORE.remove(255) # We don't have support for subfiletypes
|
||||||
LIBTIFF_CORE.remove(322) # We don't have support for writing tiled images with libtiff
|
LIBTIFF_CORE.remove(322) # We don't have support for writing tiled images with libtiff
|
||||||
LIBTIFF_CORE.remove(323) # Tiled images
|
LIBTIFF_CORE.remove(323) # Tiled images
|
||||||
LIBTIFF_CORE.remove(333) # Ink Names either
|
|
||||||
|
|
||||||
# Note to advanced users: There may be combinations of these
|
# Note to advanced users: There may be combinations of these
|
||||||
# parameters and values that when added properly, will work and
|
# parameters and values that when added properly, will work and
|
||||||
|
|
|
||||||
11
src/encode.c
11
src/encode.c
|
|
@ -668,10 +668,10 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||||
int key_int, status, is_core_tag, is_var_length, num_core_tags, i;
|
int key_int, status, is_core_tag, is_var_length, num_core_tags, i;
|
||||||
TIFFDataType type = TIFF_NOTYPE;
|
TIFFDataType type = TIFF_NOTYPE;
|
||||||
// This list also exists in TiffTags.py
|
// This list also exists in TiffTags.py
|
||||||
const int core_tags[] = {256, 257, 258, 259, 262, 263, 266, 269, 274,
|
const int core_tags[] = {256, 257, 258, 259, 262, 263, 266, 269, 274, 277,
|
||||||
277, 278, 280, 281, 340, 341, 282, 283, 284,
|
278, 280, 281, 282, 283, 284, 286, 287, 296, 297,
|
||||||
286, 287, 296, 297, 320, 321, 338, 32995, 32998,
|
301, 320, 321, 330, 333, 338, 339, 340, 341, 530,
|
||||||
32996, 339, 32997, 330, 531, 530, 65537, 301, 532};
|
531, 532, 32995, 32996, 32997, 32998, 65537};
|
||||||
|
|
||||||
Py_ssize_t tags_size;
|
Py_ssize_t tags_size;
|
||||||
PyObject *item;
|
PyObject *item;
|
||||||
|
|
@ -821,7 +821,8 @@ PyImaging_LibTiffEncoderNew(PyObject *self, PyObject *args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == TIFF_BYTE || type == TIFF_UNDEFINED) {
|
if (type == TIFF_BYTE || type == TIFF_UNDEFINED ||
|
||||||
|
key_int == TIFFTAG_INKNAMES) {
|
||||||
status = ImagingLibTiffSetField(
|
status = ImagingLibTiffSetField(
|
||||||
&encoder->state,
|
&encoder->state,
|
||||||
(ttag_t)key_int,
|
(ttag_t)key_int,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user