mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-16 19:22:39 +03:00
add libimagequant to features.py
This commit is contained in:
parent
d9dd617a8c
commit
5f4c1e113c
28
selftest.py
28
selftest.py
|
@ -2,7 +2,6 @@
|
||||||
# minimal sanity check
|
# minimal sanity check
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PIL import Image, features
|
from PIL import Image, features
|
||||||
|
@ -162,32 +161,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
exit_status = 0
|
exit_status = 0
|
||||||
|
|
||||||
print("-" * 68)
|
features.pilinfo(sys.stdout, True)
|
||||||
print("Pillow", Image.__version__, "TEST SUMMARY ")
|
|
||||||
print("-" * 68)
|
|
||||||
print("Python modules loaded from", os.path.dirname(Image.__file__))
|
|
||||||
print("Binary modules loaded from", os.path.dirname(Image.core.__file__))
|
|
||||||
print("-" * 68)
|
|
||||||
for name, feature in [
|
|
||||||
("pil", "PIL CORE"),
|
|
||||||
("tkinter", "TKINTER"),
|
|
||||||
("freetype2", "FREETYPE2"),
|
|
||||||
("littlecms2", "LITTLECMS2"),
|
|
||||||
("webp", "WEBP"),
|
|
||||||
("transp_webp", "WEBP Transparency"),
|
|
||||||
("webp_mux", "WEBPMUX"),
|
|
||||||
("webp_anim", "WEBP Animation"),
|
|
||||||
("jpg", "JPEG"),
|
|
||||||
("jpg_2000", "OPENJPEG (JPEG2000)"),
|
|
||||||
("zlib", "ZLIB (PNG/ZIP)"),
|
|
||||||
("libtiff", "LIBTIFF"),
|
|
||||||
("raqm", "RAQM (Bidirectional Text)"),
|
|
||||||
]:
|
|
||||||
if features.check(name):
|
|
||||||
print("---", feature, "support ok")
|
|
||||||
else:
|
|
||||||
print("***", feature, "support not installed")
|
|
||||||
print("-" * 68)
|
|
||||||
|
|
||||||
# use doctest to make sure the test program behaves as documented!
|
# use doctest to make sure the test program behaves as documented!
|
||||||
import doctest
|
import doctest
|
||||||
|
|
|
@ -56,6 +56,7 @@ features = {
|
||||||
"transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY"),
|
"transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY"),
|
||||||
"raqm": ("PIL._imagingft", "HAVE_RAQM"),
|
"raqm": ("PIL._imagingft", "HAVE_RAQM"),
|
||||||
"libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO"),
|
"libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO"),
|
||||||
|
"libimagequant": ("PIL._imaging", "HAVE_LIBIMAGEQUANT"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ def get_supported():
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def pilinfo(out=None):
|
def pilinfo(out=None, brief=False):
|
||||||
if out is None:
|
if out is None:
|
||||||
out = sys.stdout
|
out = sys.stdout
|
||||||
|
|
||||||
|
@ -113,11 +114,12 @@ def pilinfo(out=None):
|
||||||
)
|
)
|
||||||
print("-" * 68, file=out)
|
print("-" * 68, file=out)
|
||||||
|
|
||||||
v = sys.version.splitlines()
|
if not brief:
|
||||||
print("Python {}".format(v[0].strip()), file=out)
|
v = sys.version.splitlines()
|
||||||
for v in v[1:]:
|
print("Python {}".format(v[0].strip()), file=out)
|
||||||
print(" {}".format(v.strip()), file=out)
|
for v in v[1:]:
|
||||||
print("-" * 68, file=out)
|
print(" {}".format(v.strip()), file=out)
|
||||||
|
print("-" * 68, file=out)
|
||||||
|
|
||||||
for name, feature in [
|
for name, feature in [
|
||||||
("pil", "PIL CORE"),
|
("pil", "PIL CORE"),
|
||||||
|
@ -133,6 +135,7 @@ def pilinfo(out=None):
|
||||||
("zlib", "ZLIB (PNG/ZIP)"),
|
("zlib", "ZLIB (PNG/ZIP)"),
|
||||||
("libtiff", "LIBTIFF"),
|
("libtiff", "LIBTIFF"),
|
||||||
("raqm", "RAQM (Bidirectional Text)"),
|
("raqm", "RAQM (Bidirectional Text)"),
|
||||||
|
("libimagequant", "LIBIMAGEQUANT (quantization method)"),
|
||||||
]:
|
]:
|
||||||
if check(name):
|
if check(name):
|
||||||
print("---", feature, "support ok", file=out)
|
print("---", feature, "support ok", file=out)
|
||||||
|
@ -140,30 +143,33 @@ def pilinfo(out=None):
|
||||||
print("***", feature, "support not installed", file=out)
|
print("***", feature, "support not installed", file=out)
|
||||||
print("-" * 68, file=out)
|
print("-" * 68, file=out)
|
||||||
|
|
||||||
extensions = collections.defaultdict(list)
|
if not brief:
|
||||||
for ext, i in Image.EXTENSION.items():
|
extensions = collections.defaultdict(list)
|
||||||
extensions[i].append(ext)
|
for ext, i in Image.EXTENSION.items():
|
||||||
|
extensions[i].append(ext)
|
||||||
|
|
||||||
for i in sorted(Image.ID):
|
for i in sorted(Image.ID):
|
||||||
line = "{}".format(i)
|
line = "{}".format(i)
|
||||||
if i in Image.MIME:
|
if i in Image.MIME:
|
||||||
line = "{} {}".format(line, Image.MIME[i])
|
line = "{} {}".format(line, Image.MIME[i])
|
||||||
print(line, file=out)
|
print(line, file=out)
|
||||||
|
|
||||||
if i in extensions:
|
if i in extensions:
|
||||||
print("Extensions: {}".format(", ".join(sorted(extensions[i]))), file=out)
|
print(
|
||||||
|
"Extensions: {}".format(", ".join(sorted(extensions[i]))), file=out
|
||||||
|
)
|
||||||
|
|
||||||
features = []
|
features = []
|
||||||
if i in Image.OPEN:
|
if i in Image.OPEN:
|
||||||
features.append("open")
|
features.append("open")
|
||||||
if i in Image.SAVE:
|
if i in Image.SAVE:
|
||||||
features.append("save")
|
features.append("save")
|
||||||
if i in Image.SAVE_ALL:
|
if i in Image.SAVE_ALL:
|
||||||
features.append("save_all")
|
features.append("save_all")
|
||||||
if i in Image.DECODERS:
|
if i in Image.DECODERS:
|
||||||
features.append("decode")
|
features.append("decode")
|
||||||
if i in Image.ENCODERS:
|
if i in Image.ENCODERS:
|
||||||
features.append("encode")
|
features.append("encode")
|
||||||
|
|
||||||
print("Features: {}".format(", ".join(features)), file=out)
|
print("Features: {}".format(", ".join(features)), file=out)
|
||||||
print("-" * 68, file=out)
|
print("-" * 68, file=out)
|
||||||
|
|
|
@ -3934,6 +3934,12 @@ setup_module(PyObject* m) {
|
||||||
PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", Py_False);
|
PyModule_AddObject(m, "HAVE_LIBJPEGTURBO", Py_False);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBIMAGEQUANT
|
||||||
|
PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", Py_True);
|
||||||
|
#else
|
||||||
|
PyModule_AddObject(m, "HAVE_LIBIMAGEQUANT", Py_False);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIBZ
|
#ifdef HAVE_LIBZ
|
||||||
/* zip encoding strategies */
|
/* zip encoding strategies */
|
||||||
PyModule_AddIntConstant(m, "DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
|
PyModule_AddIntConstant(m, "DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user