- Python 2.7 or 3.3+
$ git clone --recursive https://github.com/hattya/zopfipy
$ cd zopflipy
$ python setup.py install
or
$ pip install git+https://github.com/hattya/zopflipy
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
ZopfliPy is distributed under the terms of the Apache License, Version 2.0.