谷歌guetzli的python绑定,一种优化jpeg压缩的jpeg编码器
pyguetzli的Python项目详细描述
Build StatusPYPI VersionLicense
pyguetzli是google的python绑定 Guetzli图书馆。
官方回购协议中guetzli的说明:
Guetzli is a JPEG encoder that aims for excellent compression density at high visual quality. Guetzli-generated images are typically 20-30% smaller than images of equivalent quality generated by libjpeg. Guetzli generates only sequential (nonprogressive) JPEGs due to faster decompression speeds they offer.
建造和安装Pyguetzli
为了建造Guetzli,需要GCC和GNU制造。打开(放) debian/ubuntu,可以使用以下命令安装:
sudo apt-get install build-essential
从pypi安装
要从pypi包安装pyguetzli,只需运行以下命令 命令:
pip install pyguetzli
从源安装
要从源代码构建和安装pyguetzli,请克隆存储库,然后 从项目的根目录运行pip install命令:
git clone https://github.com/wanadev/pyguetzli.git cd pyguetzli pip install .
使用pyguetzli
示例:
importpyguetzliinput_jpeg=open("./test/image.jpg","rb").read()optimized_jpeg=pyguetzli.process_jpeg_bytes(input_jpeg)output=open("./optimized.jpg","wb")output.write(optimized_jpeg)
有关详细信息,请访问项目文档:
故障排除
安装/构建pyguetzli时未声明的“nullptr”错误
Guetzli是用C++ 11编写的,所以在尝试时可能会遇到错误。
用gcc编译pyguetzli<;6.0:
...
build/temp.linux-x86_64-2.7/pyguetzli._guetzli.cpp: In function ‘int guetzli_process_rgb_bytes(char*, int, int, char**, int)’:
build/temp.linux-x86_64-2.7/pyguetzli._guetzli.cpp:474:21: error: ‘nullptr’ was not declared in this scope
Process(params, nullptr, inData, width, height, &outData);
^
error: command 'gcc' failed with exit status 1
要使用较旧的gcc版本编译pyguetzli,可以设置以下内容
环境变量:
CPPFLAGS="--std=c++11"
参见issue #1了解
更多信息。
黑客攻击
为开发安装依赖项
pip install -e .[PIL,dev]
运行测试
pip install tox tox
默认情况下,测试将在Python2.7、3.5和3.6中运行。只在 特定的python版本运行以下命令:
tox -e py27 tox -e py36
生成文档
来自虚拟机:
pip install -e .[dev] python setup.py build_sphinx
更改日志
- 1.0.8:更新guetzli和python依赖项
- 1.0.7:修复了安装pyguetzli(4)时的unicode问题
- 1.0.6:修复Unix上编译器选项中的错误
- 1.0.5:编译guetzli时添加优化标志
- 1.0.4:MS Windows支持
- 1.0.3:更新guetzli库
- 1.0.2:pil images:修复非rgb/rgba图像的崩溃 (灰度,索引,…)
- 1.0.1:在生成guetzli时添加--std=c++11标志
- 1.0.0:
- 新的更简单的API
- 内置功能,可处理PIL/枕头图像
- 文档(狮身人面像)
- guetzli更新
- 0.9.0:初始版本