Zopflipng wrapper for python,used for lossless compression of PNG
Project description
ZopfliPNG wrapper for python
This library wraps the zopflipng extension to implement lossless compression of PNG.
- Lossless compression of PNGS implemented by zopfli typically results in a compression ratio of 5% more than other lossless compression tools at the expense of longer compression time.
Install
pip install zopflipng
Usage:
# a simple example, using the default configuration
from zopflipng import png_optimize
data = open('test.png', 'rb').read()
result, code = png_optimize(data)
# if code ==0 ,png compression success
if code == 0:
# save png
with open('result.png','wb') as f:
f.write(result)
f.close()
- Use quick, but not very good, compression:
result, code = png_optimize(data, use_zopfli=False)
- Compress really good and trying all filter strategies:
result, code = png_optimize(data, lossy_8bit=True, lossy_transparent=True, filter_strategies='01234mepb', num_iterations=500)
If you want to process multiple images, use multiprocessing
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zopflipng-1.1.1.tar.gz
(158.0 kB
view hashes)
Built Distribution
Close
Hashes for zopflipng-1.1.1-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f70ed9f753c76e5dca6dbc88bf3d32c854ace7dc273d4dd4450793de6699c57 |
|
MD5 | eae0671d0ba147d6e43f2bafd125ec79 |
|
BLAKE2b-256 | 1028bf3fd12a8d649efe96d69e1a65487cdfa1b10e3bca4d39d8efee59627e69 |