Oops -- Lib/Test should be Lib/test, of course!
[python/dscho.git] / Doc / libjpeg.tex
blob76e70af7147a0315109caa02b6a05455e71c188e
1 \section{Built-in Module \module{jpeg}}
2 \label{module-jpeg}
3 \bimodindex{jpeg}
5 The module \module{jpeg} provides access to the jpeg compressor and
6 decompressor written by the Independent JPEG Group%
7 \index{Independent JPEG Group}%
8 . JPEG is a (draft?)
9 standard for compressing pictures. For details on JPEG or the
10 Independent JPEG Group software refer to the JPEG standard or the
11 documentation provided with the software.
13 The \module{jpeg} module defines an exception and some functions.
15 \begin{excdesc}{error}
16 Exception raised by \function{compress()} and \function{decompress()}
17 in case of errors.
18 \end{excdesc}
20 \begin{funcdesc}{compress}{data, w, h, b}
21 Treat data as a pixmap of width \var{w} and height \var{h}, with
22 \var{b} bytes per pixel. The data is in SGI GL order, so the first
23 pixel is in the lower-left corner. This means that \function{gl.lrectread()}
24 return data can immediately be passed to \function{compress()}.
25 Currently only 1 byte and 4 byte pixels are allowed, the former being
26 treated as greyscale and the latter as RGB color.
27 \function{compress()} returns a string that contains the compressed
28 picture, in JFIF\index{JFIF} format.
29 \end{funcdesc}
31 \begin{funcdesc}{decompress}{data}
32 Data is a string containing a picture in JFIF\index{JFIF} format. It
33 returns a tuple \code{(\var{data}, \var{width}, \var{height},
34 \var{bytesperpixel})}. Again, the data is suitable to pass to
35 \function{gl.lrectwrite()}.
36 \end{funcdesc}
38 \begin{funcdesc}{setoption}{name, value}
39 Set various options. Subsequent \function{compress()} and
40 \function{decompress()} calls will use these options. The following
41 options are available:
43 \begin{tableii}{l|p{3in}}{code}{Option}{Effect}
44 \lineii{'forcegray'}{%
45 Force output to be grayscale, even if input is RGB.}
46 \lineii{'quality'}{%
47 Set the quality of the compressed image to a value between
48 \code{0} and \code{100} (default is \code{75}). This only affects
49 compression.}
50 \lineii{'optimize'}{%
51 Perform Huffman table optimization. Takes longer, but results in
52 smaller compressed image. This only affects compression.}
53 \lineii{'smooth'}{%
54 Perform inter-block smoothing on uncompressed image. Only useful
55 for low-quality images. This only affects decompression.}
56 \end{tableii}
57 \end{funcdesc}