blob: fa7bcdee62db38dfb0fd234e1c9f8a03941d83e9 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{jpeg} ---
Fred Drake67d229e1999-02-20 04:51:16 +00002 Read and write JPEG files}
Fred Drakeb91e9341998-07-23 17:59:49 +00003
Fred Drake67d229e1999-02-20 04:51:16 +00004\declaremodule{builtin}{jpeg}
Fred Drakef6863c11999-03-02 16:37:17 +00005 \platform{IRIX}
Fred Drakeb91e9341998-07-23 17:59:49 +00006\modulesynopsis{Read and write image files in compressed JPEG format.}
7
Guido van Rossum5fdeeea1994-01-02 01:22:07 +00008
Fred Drake434493b1998-03-14 19:47:23 +00009The module \module{jpeg} provides access to the jpeg compressor and
Fred Drakefc576191998-04-04 07:15:02 +000010decompressor written by the Independent JPEG Group%
11\index{Independent JPEG Group}%
12. JPEG is a (draft?)
13standard for compressing pictures. For details on JPEG or the
Guido van Rossum16d6e711994-08-08 12:30:22 +000014Independent JPEG Group software refer to the JPEG standard or the
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000015documentation provided with the software.
16
Fred Drake434493b1998-03-14 19:47:23 +000017The \module{jpeg} module defines an exception and some functions.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000018
Fred Drake434493b1998-03-14 19:47:23 +000019\begin{excdesc}{error}
20Exception raised by \function{compress()} and \function{decompress()}
21in case of errors.
22\end{excdesc}
23
24\begin{funcdesc}{compress}{data, w, h, b}
25Treat data as a pixmap of width \var{w} and height \var{h}, with
26\var{b} bytes per pixel. The data is in SGI GL order, so the first
Fred Drakefc576191998-04-04 07:15:02 +000027pixel is in the lower-left corner. This means that \function{gl.lrectread()}
Fred Drake434493b1998-03-14 19:47:23 +000028return data can immediately be passed to \function{compress()}.
29Currently only 1 byte and 4 byte pixels are allowed, the former being
30treated as greyscale and the latter as RGB color.
31\function{compress()} returns a string that contains the compressed
Fred Drakefc576191998-04-04 07:15:02 +000032picture, in JFIF\index{JFIF} format.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000033\end{funcdesc}
34
35\begin{funcdesc}{decompress}{data}
Fred Drakefc576191998-04-04 07:15:02 +000036Data is a string containing a picture in JFIF\index{JFIF} format. It
37returns a tuple \code{(\var{data}, \var{width}, \var{height},
Fred Drake434493b1998-03-14 19:47:23 +000038\var{bytesperpixel})}. Again, the data is suitable to pass to
Fred Drakefc576191998-04-04 07:15:02 +000039\function{gl.lrectwrite()}.
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000040\end{funcdesc}
41
Fred Drake434493b1998-03-14 19:47:23 +000042\begin{funcdesc}{setoption}{name, value}
43Set various options. Subsequent \function{compress()} and
44\function{decompress()} calls will use these options. The following
45options are available:
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000046
Fred Drakeee601911998-04-11 20:53:03 +000047\begin{tableii}{l|p{3in}}{code}{Option}{Effect}
Fred Drake434493b1998-03-14 19:47:23 +000048 \lineii{'forcegray'}{%
49 Force output to be grayscale, even if input is RGB.}
50 \lineii{'quality'}{%
51 Set the quality of the compressed image to a value between
Fred Drakefab2f341998-04-11 18:46:56 +000052 \code{0} and \code{100} (default is \code{75}). This only affects
53 compression.}
Fred Drake434493b1998-03-14 19:47:23 +000054 \lineii{'optimize'}{%
55 Perform Huffman table optimization. Takes longer, but results in
Fred Drakefab2f341998-04-11 18:46:56 +000056 smaller compressed image. This only affects compression.}
Fred Drake434493b1998-03-14 19:47:23 +000057 \lineii{'smooth'}{%
58 Perform inter-block smoothing on uncompressed image. Only useful
Fred Drakefab2f341998-04-11 18:46:56 +000059 for low-quality images. This only affects decompression.}
Fred Drake434493b1998-03-14 19:47:23 +000060\end{tableii}
Guido van Rossum5fdeeea1994-01-02 01:22:07 +000061\end{funcdesc}