Server : Apache System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64 User : nobody ( 99) PHP Version : 8.1.23 Disable Function : NONE Directory : /usr/share/doc/python-docs-2.7.5/html/library/ |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>38.12. jpeg — Read and write JPEG files — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="38. SGI IRIX Specific Services" href="sgi.html" /> <link rel="next" title="39. SunOS Specific Services" href="sun.html" /> <link rel="prev" title="38.11. imgfile — Support for SGI imglib files" href="imgfile.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="sun.html" title="39. SunOS Specific Services" accesskey="N">next</a> |</li> <li class="right" > <a href="imgfile.html" title="38.11. imgfile — Support for SGI imglib files" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="sgi.html" accesskey="U">38. SGI IRIX Specific Services</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-jpeg"> <span id="jpeg-read-and-write-jpeg-files"></span><h1>38.12. <a class="reference internal" href="#module-jpeg" title="jpeg: Read and write image files in compressed JPEG format. (deprecated) (IRIX)"><tt class="xref py py-mod docutils literal"><span class="pre">jpeg</span></tt></a> — Read and write JPEG files<a class="headerlink" href="#module-jpeg" title="Permalink to this headline">¶</a></h1> <p class="deprecated"> <span class="versionmodified">Deprecated since version 2.6: </span>The <a class="reference internal" href="#module-jpeg" title="jpeg: Read and write image files in compressed JPEG format. (deprecated) (IRIX)"><tt class="xref py py-mod docutils literal"><span class="pre">jpeg</span></tt></a> module has been removed in Python 3.</p> <p id="index-0">The module <a class="reference internal" href="#module-jpeg" title="jpeg: Read and write image files in compressed JPEG format. (deprecated) (IRIX)"><tt class="xref py py-mod docutils literal"><span class="pre">jpeg</span></tt></a> provides access to the jpeg compressor and decompressor written by the Independent JPEG Group (IJG). JPEG is a standard for compressing pictures; it is defined in ISO 10918. For details on JPEG or the Independent JPEG Group software refer to the JPEG standard or the documentation provided with the software.</p> <p id="index-1">A portable interface to JPEG image files is available with the Python Imaging Library (PIL) by Fredrik Lundh. Information on PIL is available at <a class="reference external" href="http://www.pythonware.com/products/pil/">http://www.pythonware.com/products/pil/</a>.</p> <p>The <a class="reference internal" href="#module-jpeg" title="jpeg: Read and write image files in compressed JPEG format. (deprecated) (IRIX)"><tt class="xref py py-mod docutils literal"><span class="pre">jpeg</span></tt></a> module defines an exception and some functions.</p> <dl class="exception"> <dt id="jpeg.error"> <em class="property">exception </em><tt class="descclassname">jpeg.</tt><tt class="descname">error</tt><a class="headerlink" href="#jpeg.error" title="Permalink to this definition">¶</a></dt> <dd><p>Exception raised by <a class="reference internal" href="#jpeg.compress" title="jpeg.compress"><tt class="xref py py-func docutils literal"><span class="pre">compress()</span></tt></a> and <a class="reference internal" href="#jpeg.decompress" title="jpeg.decompress"><tt class="xref py py-func docutils literal"><span class="pre">decompress()</span></tt></a> in case of errors.</p> </dd></dl> <dl class="function"> <dt id="jpeg.compress"> <tt class="descclassname">jpeg.</tt><tt class="descname">compress</tt><big>(</big><em>data</em>, <em>w</em>, <em>h</em>, <em>b</em><big>)</big><a class="headerlink" href="#jpeg.compress" title="Permalink to this definition">¶</a></dt> <dd><p id="index-2">Treat data as a pixmap of width <em>w</em> and height <em>h</em>, with <em>b</em> bytes per pixel. The data is in SGI GL order, so the first pixel is in the lower-left corner. This means that <tt class="xref py py-func docutils literal"><span class="pre">gl.lrectread()</span></tt> return data can immediately be passed to <a class="reference internal" href="#jpeg.compress" title="jpeg.compress"><tt class="xref py py-func docutils literal"><span class="pre">compress()</span></tt></a>. Currently only 1 byte and 4 byte pixels are allowed, the former being treated as greyscale and the latter as RGB color. <a class="reference internal" href="#jpeg.compress" title="jpeg.compress"><tt class="xref py py-func docutils literal"><span class="pre">compress()</span></tt></a> returns a string that contains the compressed picture, in JFIF format.</p> </dd></dl> <dl class="function"> <dt id="jpeg.decompress"> <tt class="descclassname">jpeg.</tt><tt class="descname">decompress</tt><big>(</big><em>data</em><big>)</big><a class="headerlink" href="#jpeg.decompress" title="Permalink to this definition">¶</a></dt> <dd><p id="index-3">Data is a string containing a picture in JFIF format. It returns a tuple <tt class="docutils literal"><span class="pre">(data,</span> <span class="pre">width,</span> <span class="pre">height,</span> <span class="pre">bytesperpixel)</span></tt>. Again, the data is suitable to pass to <tt class="xref py py-func docutils literal"><span class="pre">gl.lrectwrite()</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="jpeg.setoption"> <tt class="descclassname">jpeg.</tt><tt class="descname">setoption</tt><big>(</big><em>name</em>, <em>value</em><big>)</big><a class="headerlink" href="#jpeg.setoption" title="Permalink to this definition">¶</a></dt> <dd><p>Set various options. Subsequent <a class="reference internal" href="#jpeg.compress" title="jpeg.compress"><tt class="xref py py-func docutils literal"><span class="pre">compress()</span></tt></a> and <a class="reference internal" href="#jpeg.decompress" title="jpeg.decompress"><tt class="xref py py-func docutils literal"><span class="pre">decompress()</span></tt></a> calls will use these options. The following options are available:</p> <table border="1" class="docutils"> <colgroup> <col width="27%" /> <col width="73%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Option</th> <th class="head">Effect</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'forcegray'</span></tt></td> <td>Force output to be grayscale, even if input is RGB.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'quality'</span></tt></td> <td>Set the quality of the compressed image to a value between <tt class="docutils literal"><span class="pre">0</span></tt> and <tt class="docutils literal"><span class="pre">100</span></tt> (default is <tt class="docutils literal"><span class="pre">75</span></tt>). This only affects compression.</td> </tr> <tr class="row-even"><td><tt class="docutils literal"><span class="pre">'optimize'</span></tt></td> <td>Perform Huffman table optimization. Takes longer, but results in smaller compressed image. This only affects compression.</td> </tr> <tr class="row-odd"><td><tt class="docutils literal"><span class="pre">'smooth'</span></tt></td> <td>Perform inter-block smoothing on uncompressed image. Only useful for low- quality images. This only affects decompression.</td> </tr> </tbody> </table> </dd></dl> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt>JPEG Still Image Data Compression Standard</dt> <dd>The canonical reference for the JPEG image format, by Pennebaker and Mitchell.</dd> <dt><a class="reference external" href="http://www.w3.org/Graphics/JPEG/itu-t81.pdf">Information Technology - Digital Compression and Coding of Continuous-tone Still Images - Requirements and Guidelines</a></dt> <dd>The ISO standard for JPEG is also published as ITU T.81. This is available online in PDF form.</dd> </dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="imgfile.html" title="previous chapter">38.11. <tt class="docutils literal"><span class="pre">imgfile</span></tt> — Support for SGI imglib files</a></p> <h4>Next topic</h4> <p class="topless"><a href="sun.html" title="next chapter">39. SunOS Specific Services</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/jpeg.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="sun.html" title="39. SunOS Specific Services" >next</a> |</li> <li class="right" > <a href="imgfile.html" title="38.11. imgfile — Support for SGI imglib files" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="sgi.html" >38. SGI IRIX Specific Services</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2020, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Oct 13, 2020. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>