cpython/Doc/lib/libjpeg.tex

53 lines
2.0 KiB
TeX
Raw Normal View History

1994-01-01 21:22:07 -04:00
\section{Built-in Module \sectcode{jpeg}}
\label{module-jpeg}
1994-01-01 21:22:07 -04:00
\bimodindex{jpeg}
1995-03-13 06:03:32 -04:00
The module \code{jpeg} provides access to the jpeg compressor and
decompressor written by the Independent JPEG Group. JPEG is a (draft?)\
1994-01-01 21:22:07 -04:00
standard for compressing pictures. For details on jpeg or the
Independent JPEG Group software refer to the JPEG standard or the
1994-01-01 21:22:07 -04:00
documentation provided with the software.
1995-03-13 06:03:32 -04:00
The \code{jpeg} module defines these functions:
1994-01-01 21:22:07 -04:00
\setindexsubitem{(in module jpeg)}
1994-01-01 21:22:07 -04:00
\begin{funcdesc}{compress}{data\, w\, h\, b}
1995-03-13 06:03:32 -04:00
Treat data as a pixmap of width \var{w} and height \var{h}, with \var{b} bytes per
pixel. The data is in SGI GL order, so the first pixel is in the
1995-03-13 06:03:32 -04:00
lower-left corner. This means that \code{lrectread} return data can
1995-04-10 08:34:00 -03:00
immediately be passed to compress. Currently only 1 byte and 4 byte
pixels are allowed, the former being treated as greyscale and the
1994-01-01 21:22:07 -04:00
latter as RGB color. Compress returns a string that contains the
compressed picture, in JFIF format.
\end{funcdesc}
\begin{funcdesc}{decompress}{data}
Data is a string containing a picture in JFIF format. It returns a
tuple
\code{(\var{data}, \var{width}, \var{height}, \var{bytesperpixel})}.
1995-03-13 06:03:32 -04:00
Again, the data is suitable to pass to \code{lrectwrite}.
1994-01-01 21:22:07 -04:00
\end{funcdesc}
\begin{funcdesc}{setoption}{name\, value}
Set various options. Subsequent compress and decompress calls
will use these options. The following options are available:
\begin{description}
1995-03-13 06:03:32 -04:00
\item[\code{'forcegray' }]
1994-01-01 21:22:07 -04:00
Force output to be grayscale, even if input is RGB.
1995-03-13 06:03:32 -04:00
\item[\code{'quality' }]
1994-01-01 21:22:07 -04:00
Set the quality of the compressed image to a
value between \code{0} and \code{100} (default is \code{75}). Compress only.
1995-03-13 06:03:32 -04:00
\item[\code{'optimize' }]
Perform Huffman table optimization. Takes longer, but results in
1994-01-01 21:22:07 -04:00
smaller compressed image. Compress only.
1995-03-13 06:03:32 -04:00
\item[\code{'smooth' }]
1994-01-01 21:22:07 -04:00
Perform inter-block smoothing on uncompressed image. Only useful for
low-quality images. Decompress only.
\end{description}
\end{funcdesc}
1995-03-13 06:03:32 -04:00
Compress and uncompress raise the error \code{jpeg.error} in case of errors.