mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 01:16:16 +03:00
Remove _webp.WebPDecoderBuggyAlpha and _webp.HAVE_TRANSPARENCY
This commit is contained in:
parent
c1e8375af8
commit
9bed5b4264
|
@ -28,7 +28,6 @@ def test_wheel_codecs() -> None:
|
||||||
def test_wheel_features() -> None:
|
def test_wheel_features() -> None:
|
||||||
expected_features = {
|
expected_features = {
|
||||||
"webp_anim",
|
"webp_anim",
|
||||||
"transp_webp",
|
|
||||||
"raqm",
|
"raqm",
|
||||||
"fribidi",
|
"fribidi",
|
||||||
"harfbuzz",
|
"harfbuzz",
|
||||||
|
|
|
@ -51,12 +51,6 @@ def test_version() -> None:
|
||||||
test(feature, features.version_feature)
|
test(feature, features.version_feature)
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("webp")
|
|
||||||
def test_webp_transparency() -> None:
|
|
||||||
assert features.check("transp_webp") != _webp.WebPDecoderBuggyAlpha()
|
|
||||||
assert features.check("transp_webp") == _webp.HAVE_TRANSPARENCY
|
|
||||||
|
|
||||||
|
|
||||||
@skip_unless_feature("webp")
|
@skip_unless_feature("webp")
|
||||||
def test_webp_anim() -> None:
|
def test_webp_anim() -> None:
|
||||||
assert features.check("webp_anim") == _webp.HAVE_WEBPANIM
|
assert features.check("webp_anim") == _webp.HAVE_WEBPANIM
|
||||||
|
|
|
@ -49,7 +49,6 @@ class TestFileWebp:
|
||||||
|
|
||||||
def test_version(self) -> None:
|
def test_version(self) -> None:
|
||||||
_webp.WebPDecoderVersion()
|
_webp.WebPDecoderVersion()
|
||||||
_webp.WebPDecoderBuggyAlpha()
|
|
||||||
version = features.version_module("webp")
|
version = features.version_module("webp")
|
||||||
assert version is not None
|
assert version is not None
|
||||||
assert re.search(r"\d+\.\d+\.\d+$", version)
|
assert re.search(r"\d+\.\d+\.\d+$", version)
|
||||||
|
|
|
@ -16,11 +16,6 @@ from .helper import (
|
||||||
_webp = pytest.importorskip("PIL._webp", reason="WebP support not installed")
|
_webp = pytest.importorskip("PIL._webp", reason="WebP support not installed")
|
||||||
|
|
||||||
|
|
||||||
def setup_module() -> None:
|
|
||||||
if _webp.WebPDecoderBuggyAlpha():
|
|
||||||
pytest.skip("Buggy early version of WebP installed, not testing transparency")
|
|
||||||
|
|
||||||
|
|
||||||
def test_read_rgba() -> None:
|
def test_read_rgba() -> None:
|
||||||
"""
|
"""
|
||||||
Can we read an RGBA mode file without error?
|
Can we read an RGBA mode file without error?
|
||||||
|
@ -81,9 +76,6 @@ def test_write_rgba(tmp_path: Path) -> None:
|
||||||
pil_image = Image.new("RGBA", (10, 10), (255, 0, 0, 20))
|
pil_image = Image.new("RGBA", (10, 10), (255, 0, 0, 20))
|
||||||
pil_image.save(temp_file)
|
pil_image.save(temp_file)
|
||||||
|
|
||||||
if _webp.WebPDecoderBuggyAlpha():
|
|
||||||
return
|
|
||||||
|
|
||||||
with Image.open(temp_file) as image:
|
with Image.open(temp_file) as image:
|
||||||
image.load()
|
image.load()
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ Feature version numbers are available only where stated.
|
||||||
Support for the following features can be checked:
|
Support for the following features can be checked:
|
||||||
|
|
||||||
* ``libjpeg_turbo``: (compile time) Whether Pillow was compiled against the libjpeg-turbo version of libjpeg. Compile-time version number is available.
|
* ``libjpeg_turbo``: (compile time) Whether Pillow was compiled against the libjpeg-turbo version of libjpeg. Compile-time version number is available.
|
||||||
* ``transp_webp``: Support for transparency in WebP images.
|
|
||||||
* ``webp_anim``: (compile time) Support for animated WebP images.
|
* ``webp_anim``: (compile time) Support for animated WebP images.
|
||||||
* ``raqm``: Raqm library, required for ``ImageFont.Layout.RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer.
|
* ``raqm``: Raqm library, required for ``ImageFont.Layout.RAQM`` in :py:func:`PIL.ImageFont.truetype`. Run-time version number is available for Raqm 0.7.0 or newer.
|
||||||
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
|
* ``libimagequant``: (compile time) ImageQuant quantization support in :py:func:`PIL.Image.Image.quantize`. Run-time version number is available.
|
||||||
|
|
|
@ -120,7 +120,6 @@ def get_supported_codecs() -> list[str]:
|
||||||
|
|
||||||
features = {
|
features = {
|
||||||
"webp_anim": ("PIL._webp", "HAVE_WEBPANIM", None),
|
"webp_anim": ("PIL._webp", "HAVE_WEBPANIM", None),
|
||||||
"transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY", None),
|
|
||||||
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
|
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
|
||||||
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
|
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
|
||||||
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
|
"harfbuzz": ("PIL._imagingft", "HAVE_HARFBUZZ", "harfbuzz_version"),
|
||||||
|
@ -270,7 +269,6 @@ def pilinfo(out: IO[str] | None = None, supported_formats: bool = True) -> None:
|
||||||
("freetype2", "FREETYPE2"),
|
("freetype2", "FREETYPE2"),
|
||||||
("littlecms2", "LITTLECMS2"),
|
("littlecms2", "LITTLECMS2"),
|
||||||
("webp", "WEBP"),
|
("webp", "WEBP"),
|
||||||
("transp_webp", "WEBP Transparency"),
|
|
||||||
("webp_anim", "WEBP Animation"),
|
("webp_anim", "WEBP Animation"),
|
||||||
("jpg", "JPEG"),
|
("jpg", "JPEG"),
|
||||||
("jpg_2000", "OPENJPEG (JPEG2000)"),
|
("jpg_2000", "OPENJPEG (JPEG2000)"),
|
||||||
|
|
27
src/_webp.c
27
src/_webp.c
|
@ -896,20 +896,6 @@ WebPDecoderVersion_str(void) {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* The version of webp that ships with (0.1.3) Ubuntu 12.04 doesn't handle alpha well.
|
|
||||||
* Files that are valid with 0.3 are reported as being invalid.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
WebPDecoderBuggyAlpha(void) {
|
|
||||||
return WebPGetDecoderVersion() == 0x0103;
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject *
|
|
||||||
WebPDecoderBuggyAlpha_wrapper() {
|
|
||||||
return Py_BuildValue("i", WebPDecoderBuggyAlpha());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/* Module Setup */
|
/* Module Setup */
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
@ -922,10 +908,6 @@ static PyMethodDef webpMethods[] = {
|
||||||
{"WebPEncode", WebPEncode_wrapper, METH_VARARGS, "WebPEncode"},
|
{"WebPEncode", WebPEncode_wrapper, METH_VARARGS, "WebPEncode"},
|
||||||
{"WebPDecode", WebPDecode_wrapper, METH_VARARGS, "WebPDecode"},
|
{"WebPDecode", WebPDecode_wrapper, METH_VARARGS, "WebPDecode"},
|
||||||
{"WebPDecoderVersion", WebPDecoderVersion_wrapper, METH_NOARGS, "WebPVersion"},
|
{"WebPDecoderVersion", WebPDecoderVersion_wrapper, METH_NOARGS, "WebPVersion"},
|
||||||
{"WebPDecoderBuggyAlpha",
|
|
||||||
WebPDecoderBuggyAlpha_wrapper,
|
|
||||||
METH_NOARGS,
|
|
||||||
"WebPDecoderBuggyAlpha"},
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -941,14 +923,6 @@ addAnimFlagToModule(PyObject *m) {
|
||||||
PyModule_AddObject(m, "HAVE_WEBPANIM", have_webpanim);
|
PyModule_AddObject(m, "HAVE_WEBPANIM", have_webpanim);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
addTransparencyFlagToModule(PyObject *m) {
|
|
||||||
PyObject *have_transparency = PyBool_FromLong(!WebPDecoderBuggyAlpha());
|
|
||||||
if (PyModule_AddObject(m, "HAVE_TRANSPARENCY", have_transparency)) {
|
|
||||||
Py_DECREF(have_transparency);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
setup_module(PyObject *m) {
|
setup_module(PyObject *m) {
|
||||||
#ifdef HAVE_WEBPANIM
|
#ifdef HAVE_WEBPANIM
|
||||||
|
@ -960,7 +934,6 @@ setup_module(PyObject *m) {
|
||||||
#endif
|
#endif
|
||||||
PyObject *d = PyModule_GetDict(m);
|
PyObject *d = PyModule_GetDict(m);
|
||||||
addAnimFlagToModule(m);
|
addAnimFlagToModule(m);
|
||||||
addTransparencyFlagToModule(m);
|
|
||||||
|
|
||||||
PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str());
|
PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str());
|
||||||
PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None);
|
PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user