PyGuetzli
=========

|Build Status| |PYPI Version| |License|

**PyGuetzli** is a Python binding for Google's
`Guetzli <https://github.com/google/guetzli>`__ library.

Description of **Guetzli** from official's repo:

    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.

Building and Installing PyGuetzli
---------------------------------

In order to build Guetzli, GCC and GNU Make are required. On
Debian / Ubuntu, this can be installed with the following command:

::

    sudo apt-get install build-essential

Installing from PYPI
~~~~~~~~~~~~~~~~~~~~

To install PyGuetzli from the PYPI package, just run the following
command:

::

    pip install pyguetzli

Installing from source
~~~~~~~~~~~~~~~~~~~~~~

To build and install PyGuetzli from source, clone the repository, and
run the ``pip install`` command from the project's root directory:

::

    git clone https://github.com/wanadev/pyguetzli.git
    cd pyguetzli
    pip install .

Using PyGuetzli
---------------

Example:

.. code:: python

    import pyguetzli

    input_jpeg = open("./test/image.jpg", "rb").read()
    optimized_jpeg = pyguetzli.process_jpeg_bytes(input_jpeg)

    output = open("./optimized.jpg", "wb")
    output.write(optimized_jpeg)

For more information, please visit the project's documentation:

-  http://wanadev.github.io/pyguetzli/

Hacking
-------

Running Tests
~~~~~~~~~~~~~

::

    pip install tox
    tox

By default test will run in Python 2.7, 3.5 and 3.6. To run only on a
specific Python version run the following commands:

::

    tox -e py27
    tox -e py35
    tox -e py36

Generating Documentation
~~~~~~~~~~~~~~~~~~~~~~~~

From a virtualenv:

::

    pip install -r requirements.txt
    python setup.py build_sphinx

Changelog
---------

-  **1.0.0**:

   -  New and simpler API
   -  Built-in function to deal with PIL / Pillow Images
   -  Documentation (Sphinx)
   -  Guetzli update

-  **0.9.0**: Initial release

.. |Build Status| image:: https://travis-ci.org/wanadev/pyguetzli.svg?branch=master
   :target: https://travis-ci.org/wanadev/pyguetzli
.. |PYPI Version| image:: https://img.shields.io/pypi/v/pyguetzli.svg
   :target: https://pypi.python.org/pypi/pyguetzli
.. |License| image:: https://img.shields.io/pypi/l/pyguetzli.svg
   :target: https://github.com/wanadev/pyguetzli/blob/master/LICENSE
