This is a Python binding for jpegtran, the lossless
jpeg image transformation software from the Independent
Jpeg Group, see www.ijg.org for more details.
The code is in the public domain.
Download
--------
python-jpegtran-0.1.tgz
Contents
--------
Makefile - makefile for building the python package
__init__.py - constructor of the package, contains
our class 'transformer' which will do the
actual transformations
jpegtran_wrap.py - a module imported by __init__
py_jpegtran.c - slightly modified copy of jpegtran.c from
the software package from www.ijg.org
py_jpegtran_wrap.c - wrapper created by SWIG
transform.c - dispatcher from python to C
README - this file
Install
-------
Get the jpeg software package of the Independent Jpeg
Group from www.ijg.org (if you don't have it already)
and unpack the tarball. The current version as of
15 October 2006 is http://www.ijg.org/files/jpegsrc.v6b.tar.gz.
Go to the directory where you are reading this README file.
Edit the first two variables in the Makefile: PYTHON_INCLUDE and
JPEG_SRC. PYTHON_INCLUDE should point to /usr/include/python2.3
or wherever the include files are for the Python distribution you want to
use with jpegtran. JPEG_SRC should point to wherever you untarred
the jpeg package from ijg.org.
Run 'make'. This will configure and build the jpeg package if
necessary and will create a directory called 'jpegtran'
containing the Python package. You may want to copy it to
/usr/lib/python2.3/site-packages or wherever the third party
packages are installed on your Python distribution.
Usage
-----
import jpegtran
transformer = jpegtran.transformer( )
transformer.rotate( 90, 'pic.jpg', 'pic_rotated.jpg' )
transformer.flip( 'horizontal', 'pic.jpg', 'pic_flipped.jpg' )
transformer.transpose( 'pic.jpg', 'pic_transposed.jpg' )
transformer.transverse( 'pic.jpg', 'pic_transversed.jpg' )
transformer.gray( 'pic.jpg', 'pic_gray.jpg' )
In the transformer = jpeg.transformer( ) call some keyword arguments
can be passed which are (with the default values):
progressive = True/False (True)
optimize = True/False (False)
trim = True/False (False)
grayscale = True/False (False)
copy = 'none', 'comments', 'all' (None = 'none')
maxmemory = an integer (None)
For the meaning of these options please see the jpegtran man page.
The code has only been tested on Python 2.3 on Linux.