【python】pillow webp折腾
前言
用python写的图像处理的程序,在开发环境(vscode)中运行的好好的,放到服务器上,就报错:PIL.UnidentifiedImageError: cannot identify image file 'data/heads/girl4.webp'
原因
我用到了python中的Pillow库,这个库正常是支持webp格式的图片处理的,但是在linux下比较特殊,还需要系统安装libwebp
排查
- 首先排除了图片原因
-
from PIL import features print(features.pilinfo())
看到输出显示:
*** WEBP support not installed
*** WEBP Transparency support not installed
*** WEBPMUX support not installed
*** WEBP Animation support not installed
安装libwebp
由于我是redhat6.9,版本非常老,只能手动安装。
wget https://github.com/webmproject/libwebp/archive/v1.2.4.tar.gz
tar -xvf v1.2.4.tar.gz
cd libwebp-1.2.4
./configure --prefix=/usr/local/libwebp
make
sudo make install
安装失败
用的python3.6版本,导致无法正常使用Pillow库,一直卡在找不到libwebp库上。
升级python3.10
先手撸一个3.10先
搞失败了
redhat6.9没法装python310,gcc版本是4.4太低了,总是编译失败。
算了。
本文来自:【python】pillow webp折腾-小码农,转载请保留本条链接,感谢!
温馨提示:
本文最后更新于 2025年03月06日,已超过 19 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
正文到此结束
- 本文标签: 开发技术 python pillow
- 本文链接: https://djc8.cn/archives/python-pillow-webp-torment.html
- 版权声明: 本文由小码农原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
热门推荐
相关文章
该篇文章的评论功能已被站长关闭