Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="prev" href="module-imgfile.html" /> | |
13 | <link rel="parent" href="sgi.html" /> | |
14 | <link rel="next" href="sunos.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>20.12 jpeg -- Read and write JPEG files</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="20.11 imgfile " | |
24 | href="module-imgfile.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="20. SGI IRIX Specific" | |
27 | href="sgi.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="21. SunOS Specific Services" | |
30 | href="sunos.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Python Library Reference</td> | |
33 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
34 | href="contents.html"><img src='../icons/contents.png' | |
35 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
36 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
37 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
38 | <td class='online-navigation'><a rel="index" title="Index" | |
39 | href="genindex.html"><img src='../icons/index.png' | |
40 | border='0' height='32' alt='Index' width='32' /></A></td> | |
41 | </tr></table> | |
42 | <div class='online-navigation'> | |
43 | <b class="navlabel">Previous:</b> | |
44 | <a class="sectref" rel="prev" href="module-imgfile.html">20.11 imgfile </A> | |
45 | <b class="navlabel">Up:</b> | |
46 | <a class="sectref" rel="parent" href="sgi.html">20. SGI IRIX Specific</A> | |
47 | <b class="navlabel">Next:</b> | |
48 | <a class="sectref" rel="next" href="sunos.html">21. SunOS Specific Services</A> | |
49 | </div> | |
50 | <hr /></div> | |
51 | </DIV> | |
52 | <!--End of Navigation Panel--> | |
53 | ||
54 | <H1><A NAME="SECTION00221200000000000000000"> | |
55 | 20.12 <tt class="module">jpeg</tt> -- | |
56 | Read and write JPEG files</A> | |
57 | </H1> | |
58 | ||
59 | <P> | |
60 | <A NAME="module-jpeg"></A> | |
61 | <p class="availability">Availability: <span | |
62 | class="platform">IRIX</span>.</p> | |
63 | ||
64 | <P> | |
65 | The module <tt class="module">jpeg</tt> provides access to the jpeg compressor and | |
66 | decompressor written by the Independent JPEG Group | |
67 | <a id='l2h-5218' xml:id='l2h-5218'></a>(IJG). JPEG is a standard for | |
68 | compressing pictures; it is defined in ISO 10918. For details on JPEG | |
69 | or the Independent JPEG Group software refer to the JPEG standard or | |
70 | the documentation provided with the software. | |
71 | ||
72 | <P> | |
73 | A portable interface to JPEG image files is available with the Python | |
74 | Imaging Library (PIL) by Fredrik Lundh. Information on PIL is | |
75 | available at <a class="url" href="http://www.pythonware.com/products/pil/">http://www.pythonware.com/products/pil/</a>. | |
76 | <a id='l2h-5219' xml:id='l2h-5219'></a> | |
77 | ||
78 | <P> | |
79 | The <tt class="module">jpeg</tt> module defines an exception and some functions. | |
80 | ||
81 | <P> | |
82 | <dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-5214' xml:id='l2h-5214' class="exception">error</tt></b></dt> | |
83 | <dd> | |
84 | Exception raised by <tt class="function">compress()</tt> and <tt class="function">decompress()</tt> | |
85 | in case of errors. | |
86 | </dd></dl> | |
87 | ||
88 | <P> | |
89 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
90 | <td><nobr><b><tt id='l2h-5215' xml:id='l2h-5215' class="function">compress</tt></b>(</nobr></td> | |
91 | <td><var>data, w, h, b</var>)</td></tr></table></dt> | |
92 | <dd> | |
93 | Treat data as a pixmap of width <var>w</var> and height <var>h</var>, with | |
94 | <var>b</var> bytes per pixel. The data is in SGI GL order, so the first | |
95 | pixel is in the lower-left corner. This means that <tt class="function">gl.lrectread()</tt> | |
96 | return data can immediately be passed to <tt class="function">compress()</tt>. | |
97 | Currently only 1 byte and 4 byte pixels are allowed, the former being | |
98 | treated as greyscale and the latter as RGB color. | |
99 | <tt class="function">compress()</tt> returns a string that contains the compressed | |
100 | picture, in JFIF<a id='l2h-5220' xml:id='l2h-5220'></a> format. | |
101 | </dl> | |
102 | ||
103 | <P> | |
104 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
105 | <td><nobr><b><tt id='l2h-5216' xml:id='l2h-5216' class="function">decompress</tt></b>(</nobr></td> | |
106 | <td><var>data</var>)</td></tr></table></dt> | |
107 | <dd> | |
108 | Data is a string containing a picture in JFIF<a id='l2h-5221' xml:id='l2h-5221'></a> format. It | |
109 | returns a tuple <code>(<var>data</var>, <var>width</var>, <var>height</var>, | |
110 | <var>bytesperpixel</var>)</code>. Again, the data is suitable to pass to | |
111 | <tt class="function">gl.lrectwrite()</tt>. | |
112 | </dl> | |
113 | ||
114 | <P> | |
115 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
116 | <td><nobr><b><tt id='l2h-5217' xml:id='l2h-5217' class="function">setoption</tt></b>(</nobr></td> | |
117 | <td><var>name, value</var>)</td></tr></table></dt> | |
118 | <dd> | |
119 | Set various options. Subsequent <tt class="function">compress()</tt> and | |
120 | <tt class="function">decompress()</tt> calls will use these options. The following | |
121 | options are available: | |
122 | ||
123 | <P> | |
124 | <div class="center"><table class="realtable"> | |
125 | <thead> | |
126 | <tr> | |
127 | <th class="left" >Option</th> | |
128 | <th class="left" >Effect</th> | |
129 | </tr> | |
130 | </thead> | |
131 | <tbody> | |
132 | <tr><td class="left" valign="baseline"><code>'forcegray'</code></td> | |
133 | <td class="left" >Force output to be grayscale, even if input is RGB.</td></tr> | |
134 | <tr><td class="left" valign="baseline"><code>'quality'</code></td> | |
135 | <td class="left" >Set the quality of the compressed image to a value between | |
136 | <code>0</code> and <code>100</code> (default is <code>75</code>). This only affects | |
137 | compression.</td></tr> | |
138 | <tr><td class="left" valign="baseline"><code>'optimize'</code></td> | |
139 | <td class="left" >Perform Huffman table optimization. Takes longer, but results in | |
140 | smaller compressed image. This only affects compression.</td></tr> | |
141 | <tr><td class="left" valign="baseline"><code>'smooth'</code></td> | |
142 | <td class="left" >Perform inter-block smoothing on uncompressed image. Only useful | |
143 | for low-quality images. This only affects decompression.</td></tr></tbody> | |
144 | </table></div> | |
145 | </dl> | |
146 | ||
147 | <P> | |
148 | <div class="seealso"> | |
149 | <p class="heading">See Also:</p> | |
150 | ||
151 | <dl compact="compact" class="seetitle"> | |
152 | <dt><em class="citetitle" | |
153 | >JPEG Still Image Data Compression Standard</em></dt> | |
154 | <dd>The | |
155 | canonical reference for the JPEG image format, by | |
156 | Pennebaker and Mitchell.</dd> | |
157 | </dl> | |
158 | ||
159 | <P> | |
160 | <dl compact="compact" class="seetitle"> | |
161 | <dt><em class="citetitle"><a href="http://www.w3.org/Graphics/JPEG/itu-t81.pdf" | |
162 | >Information | |
163 | Technology - Digital Compression and Coding of | |
164 | Continuous-tone Still Images - Requirements and | |
165 | Guidelines</a></em></dt> | |
166 | <dd>The ISO standard for JPEG is also published as | |
167 | ITU T.81. This is available online in PDF form.</dd> | |
168 | </dl> | |
169 | </div> | |
170 | ||
171 | <P> | |
172 | ||
173 | <DIV CLASS="navigation"> | |
174 | <div class='online-navigation'> | |
175 | <p></p><hr /> | |
176 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
177 | <tr> | |
178 | <td class='online-navigation'><a rel="prev" title="20.11 imgfile " | |
179 | href="module-imgfile.html"><img src='../icons/previous.png' | |
180 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
181 | <td class='online-navigation'><a rel="parent" title="20. SGI IRIX Specific" | |
182 | href="sgi.html"><img src='../icons/up.png' | |
183 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
184 | <td class='online-navigation'><a rel="next" title="21. SunOS Specific Services" | |
185 | href="sunos.html"><img src='../icons/next.png' | |
186 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
187 | <td align="center" width="100%">Python Library Reference</td> | |
188 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
189 | href="contents.html"><img src='../icons/contents.png' | |
190 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
191 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
192 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
193 | <td class='online-navigation'><a rel="index" title="Index" | |
194 | href="genindex.html"><img src='../icons/index.png' | |
195 | border='0' height='32' alt='Index' width='32' /></A></td> | |
196 | </tr></table> | |
197 | <div class='online-navigation'> | |
198 | <b class="navlabel">Previous:</b> | |
199 | <a class="sectref" rel="prev" href="module-imgfile.html">20.11 imgfile </A> | |
200 | <b class="navlabel">Up:</b> | |
201 | <a class="sectref" rel="parent" href="sgi.html">20. SGI IRIX Specific</A> | |
202 | <b class="navlabel">Next:</b> | |
203 | <a class="sectref" rel="next" href="sunos.html">21. SunOS Specific Services</A> | |
204 | </div> | |
205 | </div> | |
206 | <hr /> | |
207 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
208 | </DIV> | |
209 | <!--End of Navigation Panel--> | |
210 | <ADDRESS> | |
211 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
212 | </ADDRESS> | |
213 | </BODY> | |
214 | </HTML> |