https://github.com/hhoy/python-zopflipng
Lossless PNG compressor - Use the zopfli compression algorithm,It works in python
https://github.com/hhoy/python-zopflipng
image-compression png png-compression png-optimizer python-library python3 zopfli zopflipng
Last synced: about 1 year ago
JSON representation
Lossless PNG compressor - Use the zopfli compression algorithm,It works in python
- Host: GitHub
- URL: https://github.com/hhoy/python-zopflipng
- Owner: hhoy
- License: apache-2.0
- Created: 2020-02-16T13:58:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-17T10:38:18.000Z (over 6 years ago)
- Last Synced: 2025-04-22T11:19:42.191Z (about 1 year ago)
- Topics: image-compression, png, png-compression, png-optimizer, python-library, python3, zopfli, zopflipng
- Language: Python
- Homepage:
- Size: 214 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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