A Python bindings for Zopfli
Project Links
Meta
Author: Akinori Hattori
Requires Python: >=3.9
Classifiers
Development Status
- 5 - Production/Stable
Intended Audience
- Developers
License
- OSI Approved :: Apache Software License
Operating System
- OS Independent
Programming Language
- C
- C++
- Python :: 3
- Python :: 3.9
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Topic
- Software Development :: Libraries :: Python Modules
- System :: Archiving :: Compression
Installation
$ pip install zopflipy
Requirements
Python 3.9+
Usage
ZopfliCompressor
>>> import zopfli
>>> c = zopfli.ZopfliCompressor(zopfli.ZOPFLI_FORMAT_DEFLATE)
>>> z = c.compress(b'Hello, world!') + c.flush()
>>> d = zopfli.ZopfliDecompressor(zopfli.ZOPFLI_FORMAT_DEFLATE)
>>> d.decompress(z) + d.flush()
b'Hello, world!''
ZopfliDeflater
>>> import zopfli
>>> c = zopfli.ZopfliDeflater()
>>> z = c.compress(b'Hello, world!') + c.flush()
>>> d = zopfli.ZopfliDecompressor(zopfli.ZOPFLI_FORMAT_DEFLATE)
>>> d.decompress(z) + d.flush()
b'Hello, world!''
ZopfliPNG
>>> import zopfli
>>> png = zopfli.ZopfliPNG()
>>> with open('in.png', 'rb') as fp:
... data = fp.read()
>>> len(png.optimize(data)) < len(data)
True
ZipFile
A subclass of zipfile.ZipFile which uses ZopfliCompressor for the zipfile.ZIP_DEFLATED compression method.
>>> import zipfile
>>> import zopfli
>>> with zopfli.ZipFile('a.zip', 'w', zipfile.ZIP_DEFLATED) as zf:
... zf.writestr('a.txt', b'Hello, world!')
License
ZopfliPy is distributed under the terms of the Apache License, Version 2.0.
Oct 18, 2024
1.11
Feb 04, 2024
1.10
Oct 15, 2023
1.9
Nov 08, 2022
1.8
Nov 07, 2021
1.7
Aug 30, 2021
1.6
Jan 11, 2021
1.5
Nov 08, 2020
1.4
Dec 04, 2019
1.3
Nov 27, 2019
1.2
Jul 17, 2018
1.1
Sep 26, 2017
1.0
Wheel compatibility matrix
Files in release
No dependencies