1 \section{Built-in Module
\sectcode{jpeg
}}
4 The module
\code{jpeg
} provides access to the jpeg compressor and
5 decompressor written by the Independent JPEG Group. JPEG is a (draft?)\
6 standard for compressing pictures. For details on jpeg or the
7 Independent JPEG Group software refer to the JPEG standard or the
8 documentation provided with the software.
10 The
\code{jpeg
} module defines these functions:
12 \renewcommand{\indexsubitem}{(in module jpeg)
}
13 \begin{funcdesc
}{compress
}{data\, w\, h\, b
}
14 Treat data as a pixmap of width
\var{w
} and height
\var{h
}, with
\var{b
} bytes per
15 pixel. The data is in SGI GL order, so the first pixel is in the
16 lower-left corner. This means that
\code{lrectread
} return data can
17 immediately be passed to compress. Currently only
1 byte and
4 byte
18 pixels are allowed, the former being treated as greyscale and the
19 latter as RGB
color. Compress returns a string that contains the
20 compressed picture, in JFIF format.
23 \begin{funcdesc
}{decompress
}{data
}
24 Data is a string containing a picture in JFIF format. It returns a
26 \code{(
\var{data
},
\var{width
},
\var{height
},
\var{bytesperpixel
})
}.
27 Again, the data is suitable to pass to
\code{lrectwrite
}.
30 \begin{funcdesc
}{setoption
}{name\, value
}
31 Set various options. Subsequent compress and decompress calls
32 will use these options. The following options are available:
34 \item[\code{'forcegray'
}]
35 Force output to be grayscale, even if input is RGB.
37 \item[\code{'quality'
}]
38 Set the quality of the compressed image to a
39 value between
\code{0} and
\code{100} (default is
\code{75}). Compress only.
41 \item[\code{'optimize'
}]
42 Perform Huffman table optimization. Takes longer, but results in
43 smaller compressed image. Compress only.
45 \item[\code{'smooth'
}]
46 Perform inter-block smoothing on uncompressed image. Only useful for
47 low-quality images. Decompress only.
51 Compress and uncompress raise the error
\code{jpeg.error
} in case of errors.