Skip to content
Python cffi libjpeg-turbo bindings and helper classes
Python
Branch: master
Clone or download

Latest commit

Latest commit 98bdfe9 Feb 23, 2018

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/jpeg4py Changed cleanup of cached decompressors to manual Apr 9, 2017
tests Fixed bugs, added tests/benchmark.py Mar 20, 2014
.gitignore Initial commit Mar 18, 2014
LICENSE Created initial directory structure Mar 18, 2014
MANIFEST.in Fixed bugs, added tests/benchmark.py Mar 20, 2014
README Created initial directory structure Mar 18, 2014
README.md Added Windows and Mac OS X support Mar 24, 2016
setup.py Changed version to 0.1.4 Feb 23, 2018

README.md

jpeg4py

Python cffi libjpeg-turbo bindings and helper classes.

The purpose of this package is to provide thread-safe and aware of GIL Python bindings to libjpeg-turbo which work with numpy arrays on Python 2, 3 and PyPy.

Tested with Python 2.7, Python 3.4 and PyPy on Ubuntu 14.04.

Covered TurboJPEG API:

tjInitDecompress
tjDecompressHeader2
tjDecompress2

so, currently, only decoding of jpeg files is possible, and it is about 1.3 times faster than Image.open().tobytes() and scipy.misc.imread() in a single thread and up to 9 times faster in multithreaded mode.

Installation

Requirements:

  1. numpy
  2. libjpeg-turbo

On Ubuntu, the shared library is included in libturbojpeg package:

sudo apt-get install libturbojpeg

On Windows, you can download installer from the official libjpeg-turbo Sourceforge repository, install it and copy turbojpeg.dll to the directory from the system PATH.

On Mac OS X, you can download the DMG from the official libjpeg-turbo Sourceforge repository and install it.

If you have a custom library which is TurboJPEG API compatible, just call jpeg4py.initialize with tuple containing that library's file name.

To install the module run:

python -m pip install jpeg4py

or

python setup.py install

or just copy src/jpeg4py to any place where python interpreter will be able to find it.

Tests

To run the tests, execute:

PYTHONPATH=src python -m nose -w tests

Example usage:

import jpeg4py as jpeg
import matplotlib.pyplot as pp


if __name__ == "__main__":
    pp.imshow(jpeg.JPEG("test.jpg").decode())
    pp.show()

License

Released under Simplified BSD License. Copyright (c) 2014, Samsung Electronics Co.,Ltd.

You can’t perform that action at this time.