mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +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:
 | 
			
		||||
    expected_features = {
 | 
			
		||||
        "webp_anim",
 | 
			
		||||
        "transp_webp",
 | 
			
		||||
        "raqm",
 | 
			
		||||
        "fribidi",
 | 
			
		||||
        "harfbuzz",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -51,12 +51,6 @@ def test_version() -> None:
 | 
			
		|||
        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")
 | 
			
		||||
def test_webp_anim() -> None:
 | 
			
		||||
    assert features.check("webp_anim") == _webp.HAVE_WEBPANIM
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,7 +49,6 @@ class TestFileWebp:
 | 
			
		|||
 | 
			
		||||
    def test_version(self) -> None:
 | 
			
		||||
        _webp.WebPDecoderVersion()
 | 
			
		||||
        _webp.WebPDecoderBuggyAlpha()
 | 
			
		||||
        version = features.version_module("webp")
 | 
			
		||||
        assert version is not None
 | 
			
		||||
        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")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def setup_module() -> None:
 | 
			
		||||
    if _webp.WebPDecoderBuggyAlpha():
 | 
			
		||||
        pytest.skip("Buggy early version of WebP installed, not testing transparency")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_read_rgba() -> None:
 | 
			
		||||
    """
 | 
			
		||||
    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.save(temp_file)
 | 
			
		||||
 | 
			
		||||
    if _webp.WebPDecoderBuggyAlpha():
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    with Image.open(temp_file) as image:
 | 
			
		||||
        image.load()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,7 +54,6 @@ Feature version numbers are available only where stated.
 | 
			
		|||
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.
 | 
			
		||||
* ``transp_webp``: Support for transparency in 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.
 | 
			
		||||
* ``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 = {
 | 
			
		||||
    "webp_anim": ("PIL._webp", "HAVE_WEBPANIM", None),
 | 
			
		||||
    "transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY", None),
 | 
			
		||||
    "raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
 | 
			
		||||
    "fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_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"),
 | 
			
		||||
        ("littlecms2", "LITTLECMS2"),
 | 
			
		||||
        ("webp", "WEBP"),
 | 
			
		||||
        ("transp_webp", "WEBP Transparency"),
 | 
			
		||||
        ("webp_anim", "WEBP Animation"),
 | 
			
		||||
        ("jpg", "JPEG"),
 | 
			
		||||
        ("jpg_2000", "OPENJPEG (JPEG2000)"),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										27
									
								
								src/_webp.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								src/_webp.c
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -896,20 +896,6 @@ WebPDecoderVersion_str(void) {
 | 
			
		|||
    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                                                         */
 | 
			
		||||
/* -------------------------------------------------------------------- */
 | 
			
		||||
| 
						 | 
				
			
			@ -922,10 +908,6 @@ static PyMethodDef webpMethods[] = {
 | 
			
		|||
    {"WebPEncode", WebPEncode_wrapper, METH_VARARGS, "WebPEncode"},
 | 
			
		||||
    {"WebPDecode", WebPDecode_wrapper, METH_VARARGS, "WebPDecode"},
 | 
			
		||||
    {"WebPDecoderVersion", WebPDecoderVersion_wrapper, METH_NOARGS, "WebPVersion"},
 | 
			
		||||
    {"WebPDecoderBuggyAlpha",
 | 
			
		||||
     WebPDecoderBuggyAlpha_wrapper,
 | 
			
		||||
     METH_NOARGS,
 | 
			
		||||
     "WebPDecoderBuggyAlpha"},
 | 
			
		||||
    {NULL, NULL}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -941,14 +923,6 @@ addAnimFlagToModule(PyObject *m) {
 | 
			
		|||
    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
 | 
			
		||||
setup_module(PyObject *m) {
 | 
			
		||||
#ifdef HAVE_WEBPANIM
 | 
			
		||||
| 
						 | 
				
			
			@ -960,7 +934,6 @@ setup_module(PyObject *m) {
 | 
			
		|||
#endif
 | 
			
		||||
    PyObject *d = PyModule_GetDict(m);
 | 
			
		||||
    addAnimFlagToModule(m);
 | 
			
		||||
    addTransparencyFlagToModule(m);
 | 
			
		||||
 | 
			
		||||
    PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str());
 | 
			
		||||
    PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user