diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 72f732d78..9fab41746 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -48,7 +48,7 @@ def test_sanity(): assert list(map(type, v)) == [str, str, str, str] # internal version number - assert re.search(r"\d+\.\d+$", features.version_module("littlecms2")) + assert re.search(r"\d+\.\d+(\.\d+)?$", features.version_module("littlecms2")) skip_missing() i = ImageCms.profileToProfile(hopper(), SRGB, SRGB) diff --git a/src/PIL/features.py b/src/PIL/features.py index fa86b9cb0..c2df9c525 100644 --- a/src/PIL/features.py +++ b/src/PIL/features.py @@ -224,6 +224,8 @@ def pilinfo(out=None, supported_formats=True): If ``True``, a list of all supported image file formats will be printed. """ + from pkg_resources import parse_version + if out is None: out = sys.stdout @@ -269,7 +271,10 @@ def pilinfo(out=None, supported_formats=True): else: v = version(name) if v is not None: - t = "compiled for" if name in ("pil", "jpg") else "loaded" + version_static = name in ("pil", "jpg") + if name == "littlecms2": + version_static = parse_version(v) < parse_version("2.7.0") + t = "compiled for" if version_static else "loaded" print("---", feature, "support ok,", t, v, file=out) else: print("---", feature, "support ok", file=out) diff --git a/src/_imagingcms.c b/src/_imagingcms.c index cba41ec90..59c7318a9 100644 --- a/src/_imagingcms.c +++ b/src/_imagingcms.c @@ -1512,8 +1512,16 @@ setup_module(PyObject* m) { d = PyModule_GetDict(m); +#if LCMS_VERSION < 2070 + vn = LCMS_VERSION; +#else vn = cmsGetEncodedCMMversion(); - v = PyUnicode_FromFormat("%d.%d", vn / 100, vn % 100); +#endif + if (vn % 10) { + v = PyUnicode_FromFormat("%d.%d.%d", vn / 1000, (vn / 10) % 100, vn % 10); + } else { + v = PyUnicode_FromFormat("%d.%d", vn / 1000, (vn / 10) % 100); + } PyDict_SetItemString(d, "littlecms_version", v); return 0;