mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Require webpmux and webpdemux
This commit is contained in:
parent
a5b415bef5
commit
c1e8375af8
|
@ -28,7 +28,6 @@ def test_wheel_codecs() -> None:
|
|||
def test_wheel_features() -> None:
|
||||
expected_features = {
|
||||
"webp_anim",
|
||||
"webp_mux",
|
||||
"transp_webp",
|
||||
"raqm",
|
||||
"fribidi",
|
||||
|
|
|
@ -57,11 +57,6 @@ def test_webp_transparency() -> None:
|
|||
assert features.check("transp_webp") == _webp.HAVE_TRANSPARENCY
|
||||
|
||||
|
||||
@skip_unless_feature("webp")
|
||||
def test_webp_mux() -> None:
|
||||
assert features.check("webp_mux") == _webp.HAVE_WEBPMUX
|
||||
|
||||
|
||||
@skip_unless_feature("webp")
|
||||
def test_webp_anim() -> None:
|
||||
assert features.check("webp_anim") == _webp.HAVE_WEBPANIM
|
||||
|
|
|
@ -10,10 +10,7 @@ from PIL import Image
|
|||
|
||||
from .helper import mark_if_feature_version, skip_unless_feature
|
||||
|
||||
pytestmark = [
|
||||
skip_unless_feature("webp"),
|
||||
skip_unless_feature("webp_mux"),
|
||||
]
|
||||
pytestmark = [skip_unless_feature("webp")]
|
||||
|
||||
ElementTree: ModuleType | None
|
||||
try:
|
||||
|
|
|
@ -1252,16 +1252,13 @@ The :py:meth:`~PIL.Image.Image.save` method supports the following options:
|
|||
Requires libwebp 0.5.0 or later.
|
||||
|
||||
**icc_profile**
|
||||
The ICC Profile to include in the saved file. Only supported if
|
||||
the system WebP library was built with webpmux support.
|
||||
The ICC Profile to include in the saved file.
|
||||
|
||||
**exif**
|
||||
The exif data to include in the saved file. Only supported if
|
||||
the system WebP library was built with webpmux support.
|
||||
The exif data to include in the saved file.
|
||||
|
||||
**xmp**
|
||||
The XMP data to include in the saved file. Only supported if
|
||||
the system WebP library was built with webpmux support.
|
||||
The XMP data to include in the saved file.
|
||||
|
||||
Saving sequences
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -275,18 +275,18 @@ Build Options
|
|||
|
||||
* Config settings: ``-C zlib=disable``, ``-C jpeg=disable``,
|
||||
``-C tiff=disable``, ``-C freetype=disable``, ``-C raqm=disable``,
|
||||
``-C lcms=disable``, ``-C webp=disable``, ``-C webpmux=disable``,
|
||||
``-C lcms=disable``, ``-C webp=disable``,
|
||||
``-C jpeg2000=disable``, ``-C imagequant=disable``, ``-C xcb=disable``.
|
||||
Disable building the corresponding feature even if the development
|
||||
libraries are present on the building machine.
|
||||
|
||||
* Config settings: ``-C zlib=enable``, ``-C jpeg=enable``,
|
||||
``-C tiff=enable``, ``-C freetype=enable``, ``-C raqm=enable``,
|
||||
``-C lcms=enable``, ``-C webp=enable``, ``-C webpmux=enable``,
|
||||
``-C lcms=enable``, ``-C webp=enable``,
|
||||
``-C jpeg2000=enable``, ``-C imagequant=enable``, ``-C xcb=enable``.
|
||||
Require that the corresponding feature is built. The build will raise
|
||||
an exception if the libraries are not found. Webpmux (WebP metadata)
|
||||
relies on WebP support. Tcl and Tk also must be used together.
|
||||
an exception if the libraries are not found. Tcl and Tk must be used
|
||||
together.
|
||||
|
||||
* Config settings: ``-C raqm=vendor``, ``-C fribidi=vendor``.
|
||||
These flags are used to compile a modified version of libraqm and
|
||||
|
|
|
@ -55,7 +55,6 @@ 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_mux``: (compile time) Support for EXIF data 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.
|
||||
|
|
46
setup.py
46
setup.py
|
@ -295,7 +295,6 @@ class pil_build_ext(build_ext):
|
|||
"raqm",
|
||||
"lcms",
|
||||
"webp",
|
||||
"webpmux",
|
||||
"jpeg2000",
|
||||
"imagequant",
|
||||
"xcb",
|
||||
|
@ -794,29 +793,22 @@ class pil_build_ext(build_ext):
|
|||
|
||||
if feature.want("webp"):
|
||||
_dbg("Looking for webp")
|
||||
if _find_include_file(self, "webp/encode.h") and _find_include_file(
|
||||
self, "webp/decode.h"
|
||||
if all(
|
||||
_find_include_file(self, src)
|
||||
for src in ["webp/encode.h", "webp/mux.h", "webp/demux.h"]
|
||||
):
|
||||
# In Google's precompiled zip it is call "libwebp":
|
||||
if _find_library_file(self, "webp"):
|
||||
if all(
|
||||
_find_library_file(self, lib)
|
||||
for lib in ["webp", "webpmux", "webpdemux"]
|
||||
):
|
||||
feature.webp = "webp"
|
||||
elif _find_library_file(self, "libwebp"):
|
||||
elif all(
|
||||
_find_library_file(self, lib)
|
||||
for lib in ["libwebp", "libwebpmux", "libwebpdemux"]
|
||||
):
|
||||
feature.webp = "libwebp"
|
||||
|
||||
if feature.want("webpmux"):
|
||||
_dbg("Looking for webpmux")
|
||||
if _find_include_file(self, "webp/mux.h") and _find_include_file(
|
||||
self, "webp/demux.h"
|
||||
):
|
||||
if _find_library_file(self, "webpmux") and _find_library_file(
|
||||
self, "webpdemux"
|
||||
):
|
||||
feature.webpmux = "webpmux"
|
||||
if _find_library_file(self, "libwebpmux") and _find_library_file(
|
||||
self, "libwebpdemux"
|
||||
):
|
||||
feature.webpmux = "libwebpmux"
|
||||
|
||||
if feature.want("xcb"):
|
||||
_dbg("Looking for xcb")
|
||||
if _find_include_file(self, "xcb/xcb.h"):
|
||||
|
@ -904,15 +896,12 @@ class pil_build_ext(build_ext):
|
|||
self._remove_extension("PIL._imagingcms")
|
||||
|
||||
if feature.webp:
|
||||
libs = [feature.webp]
|
||||
defs = []
|
||||
|
||||
if feature.webpmux:
|
||||
defs.append(("HAVE_WEBPMUX", None))
|
||||
libs.append(feature.webpmux)
|
||||
libs.append(feature.webpmux.replace("pmux", "pdemux"))
|
||||
|
||||
self._update_extension("PIL._webp", libs, defs)
|
||||
libs = [
|
||||
feature.webp,
|
||||
feature.webp + "mux",
|
||||
feature.webp + "demux",
|
||||
]
|
||||
self._update_extension("PIL._webp", libs, [])
|
||||
else:
|
||||
self._remove_extension("PIL._webp")
|
||||
|
||||
|
@ -953,7 +942,6 @@ class pil_build_ext(build_ext):
|
|||
(feature.raqm, "RAQM (Text shaping)", raqm_extra_info),
|
||||
(feature.lcms, "LITTLECMS2"),
|
||||
(feature.webp, "WEBP"),
|
||||
(feature.webpmux, "WEBPMUX"),
|
||||
(feature.xcb, "XCB (X protocol)"),
|
||||
]
|
||||
|
||||
|
|
|
@ -120,7 +120,6 @@ def get_supported_codecs() -> list[str]:
|
|||
|
||||
features = {
|
||||
"webp_anim": ("PIL._webp", "HAVE_WEBPANIM", None),
|
||||
"webp_mux": ("PIL._webp", "HAVE_WEBPMUX", None),
|
||||
"transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY", None),
|
||||
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_version"),
|
||||
"fribidi": ("PIL._imagingft", "HAVE_FRIBIDI", "fribidi_version"),
|
||||
|
@ -272,7 +271,6 @@ def pilinfo(out: IO[str] | None = None, supported_formats: bool = True) -> None:
|
|||
("littlecms2", "LITTLECMS2"),
|
||||
("webp", "WEBP"),
|
||||
("transp_webp", "WEBP Transparency"),
|
||||
("webp_mux", "WEBPMUX"),
|
||||
("webp_anim", "WEBP Animation"),
|
||||
("jpg", "JPEG"),
|
||||
("jpg_2000", "OPENJPEG (JPEG2000)"),
|
||||
|
|
33
src/_webp.c
33
src/_webp.c
|
@ -4,8 +4,6 @@
|
|||
#include <webp/encode.h>
|
||||
#include <webp/decode.h>
|
||||
#include <webp/types.h>
|
||||
|
||||
#ifdef HAVE_WEBPMUX
|
||||
#include <webp/mux.h>
|
||||
#include <webp/demux.h>
|
||||
|
||||
|
@ -19,8 +17,6 @@
|
|||
#define HAVE_WEBPANIM
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
ImagingSectionEnter(ImagingSectionCookie *cookie) {
|
||||
*cookie = (PyThreadState *)PyEval_SaveThread();
|
||||
|
@ -35,8 +31,6 @@ ImagingSectionLeave(ImagingSectionCookie *cookie) {
|
|||
/* WebP Muxer Error Handling */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_WEBPMUX
|
||||
|
||||
static const char *const kErrorMessages[-WEBP_MUX_NOT_ENOUGH_DATA + 1] = {
|
||||
"WEBP_MUX_NOT_FOUND",
|
||||
"WEBP_MUX_INVALID_ARGUMENT",
|
||||
|
@ -89,8 +83,6 @@ HandleMuxError(WebPMuxError err, char *chunk) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* WebP Animation Support */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -693,13 +685,6 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
|||
output = writer.mem;
|
||||
ret_size = writer.size;
|
||||
|
||||
#ifndef HAVE_WEBPMUX
|
||||
if (ret_size > 0) {
|
||||
PyObject *ret = PyBytes_FromStringAndSize((char *)output, ret_size);
|
||||
free(output);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
{
|
||||
/* I want to truncate the *_size items that get passed into WebP
|
||||
data. Pypy2.1.0 had some issues where the Py_ssize_t items had
|
||||
|
@ -775,7 +760,6 @@ WebPEncode_wrapper(PyObject *self, PyObject *args) {
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
@ -809,9 +793,6 @@ WebPDecode_wrapper(PyObject *self, PyObject *args) {
|
|||
mode = "RGBA";
|
||||
}
|
||||
|
||||
#ifndef HAVE_WEBPMUX
|
||||
vp8_status_code = WebPDecode(webp, size, &config);
|
||||
#else
|
||||
{
|
||||
int copy_data = 0;
|
||||
WebPData data = {webp, size};
|
||||
|
@ -849,7 +830,6 @@ WebPDecode_wrapper(PyObject *self, PyObject *args) {
|
|||
WebPDataClear(&image.bitstream);
|
||||
WebPMuxDelete(mux);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (vp8_status_code != VP8_STATUS_OK) {
|
||||
|
@ -949,18 +929,6 @@ static PyMethodDef webpMethods[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
void
|
||||
addMuxFlagToModule(PyObject *m) {
|
||||
PyObject *have_webpmux;
|
||||
#ifdef HAVE_WEBPMUX
|
||||
have_webpmux = Py_True;
|
||||
#else
|
||||
have_webpmux = Py_False;
|
||||
#endif
|
||||
Py_INCREF(have_webpmux);
|
||||
PyModule_AddObject(m, "HAVE_WEBPMUX", have_webpmux);
|
||||
}
|
||||
|
||||
void
|
||||
addAnimFlagToModule(PyObject *m) {
|
||||
PyObject *have_webpanim;
|
||||
|
@ -991,7 +959,6 @@ setup_module(PyObject *m) {
|
|||
}
|
||||
#endif
|
||||
PyObject *d = PyModule_GetDict(m);
|
||||
addMuxFlagToModule(m);
|
||||
addAnimFlagToModule(m);
|
||||
addTransparencyFlagToModule(m);
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ DEPS = {
|
|||
},
|
||||
"build": [
|
||||
*cmds_cmake(
|
||||
"webp webpdemux webpmux",
|
||||
"webp webpmux webpdemux",
|
||||
"-DBUILD_SHARED_LIBS:BOOL=OFF",
|
||||
"-DWEBP_LINK_STATIC:BOOL=OFF",
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue
Block a user