How can a deployment check for WebP support at runtime?
features.check queries whether the current Pillow build provides a named feature or module.
Pixel experiment and interpretation
Two machines may run the same reader with different builds. Probe webp before choosing an input format. The example result describes only the verified runtime.
from PIL import features
features.check('webp')Result True
中文
部署时如何检测运行环境是否支持 WebP 编解码?
features.check 可查询当前 Pillow 构建是否具备指定模块或功能。
像素实验与适用边界
同一个读取程序在两台机器上可能安装了不同构建。启动时检查 webp 并据此选择输入格式;示例结果仅代表本次验证环境。
from PIL import features
features.check('webp')结果 True