mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-11 17:56:18 +03:00
Support saving CMYK JPEG2000 images
This commit is contained in:
parent
d66c51a356
commit
522505b714
|
@ -325,6 +325,18 @@ def test_cmyk() -> None:
|
|||
assert im.getpixel((0, 0)) == (185, 134, 0, 0)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
not os.path.exists(EXTRA_DIR), reason="Extra image files not installed"
|
||||
)
|
||||
@skip_unless_feature_version("jpg_2000", "2.5.3")
|
||||
def test_cmyk_save() -> None:
|
||||
with Image.open(f"{EXTRA_DIR}/issue205.jp2") as jp2:
|
||||
assert jp2.mode == "CMYK"
|
||||
|
||||
im = roundtrip(jp2)
|
||||
assert_image_equal(im, jp2)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ext", (".j2k", ".jp2"))
|
||||
def test_16bit_monochrome_has_correct_mode(ext: str) -> None:
|
||||
with Image.open("Tests/images/16bit.cropped" + ext) as im:
|
||||
|
|
|
@ -330,6 +330,13 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) {
|
|||
components = 4;
|
||||
color_space = OPJ_CLRSPC_SRGB;
|
||||
pack = j2k_pack_rgba;
|
||||
#if ((OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 5 && OPJ_VERSION_BUILD >= 3) || \
|
||||
(OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR > 5) || OPJ_VERSION_MAJOR > 2)
|
||||
} else if (strcmp(im->mode, "CMYK") == 0) {
|
||||
components = 4;
|
||||
color_space = OPJ_CLRSPC_CMYK;
|
||||
pack = j2k_pack_rgba;
|
||||
#endif
|
||||
} else {
|
||||
state->errcode = IMAGING_CODEC_BROKEN;
|
||||
state->state = J2K_STATE_FAILED;
|
||||
|
|
Loading…
Reference in New Issue
Block a user