Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 13f150929e9d4281f1fa1d3f36c1073a > files > 123

python-pillow-doc-2.6.2-1.1.mga4.noarch.rpm



<!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>ImageFile Module &mdash; Pillow v2.6.2 (PIL fork)</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.6.2',
        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>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="top" title="Pillow v2.6.2 (PIL fork)" href="../index.html" />
    <link rel="up" title="Reference" href="index.html" />
    <link rel="next" title="ImageFilter Module" href="ImageFilter.html" />
    <link rel="prev" title="ImageEnhance Module" href="ImageEnhance.html" /> 
  </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="ImageFilter.html" title="ImageFilter Module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="ImageEnhance.html" title="ImageEnhance Module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Home</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">Reference</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <span class="target" id="module-PIL.ImageFile"></span><div class="section" id="imagefile-module">
<h1><tt class="xref py py-mod docutils literal"><span class="pre">ImageFile</span></tt> Module<a class="headerlink" href="#imagefile-module" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="xref py py-mod docutils literal"><span class="pre">ImageFile</span></tt> module provides support functions for the image open
and save functions.</p>
<p>In addition, it provides a <tt class="xref py py-class docutils literal"><span class="pre">Parser</span></tt> class which can be used to decode
an image piece by piece (e.g. while receiving it over a network connection).
This class implements the same consumer interface as the standard <strong>sgmllib</strong>
and <strong>xmllib</strong> modules.</p>
<div class="section" id="example-parse-an-image">
<h2>Example: Parse an image<a class="headerlink" href="#example-parse-an-image" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">PIL</span> <span class="kn">import</span> <span class="n">ImageFile</span>

<span class="n">fp</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="s">&quot;lena.pgm&quot;</span><span class="p">,</span> <span class="s">&quot;rb&quot;</span><span class="p">)</span>

<span class="n">p</span> <span class="o">=</span> <span class="n">ImageFile</span><span class="o">.</span><span class="n">Parser</span><span class="p">()</span>

<span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
    <span class="n">s</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">s</span><span class="p">:</span>
        <span class="k">break</span>
    <span class="n">p</span><span class="o">.</span><span class="n">feed</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>

<span class="n">im</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

<span class="n">im</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="s">&quot;copy.jpg&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="parser">
<h2><tt class="xref py py-class docutils literal"><span class="pre">Parser</span></tt><a class="headerlink" href="#parser" title="Permalink to this headline">¶</a></h2>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><tt class="docutils literal"><span class="pre">ImageFile</span></tt> Module</a><ul>
<li><a class="reference internal" href="#example-parse-an-image">Example: Parse an image</a></li>
<li><a class="reference internal" href="#parser"><tt class="docutils literal"><span class="pre">Parser</span></tt></a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/reference/ImageFile.txt"
           rel="nofollow">Show Source</a></li>
  </ul><h3>Need help?</h3>
<p>
    You can get help via IRC at <a href="irc://irc.freenode.net#pil">irc://irc.freenode.net#pil</a> or Stack Overflow <a href="http://stackoverflow.com/questions/tagged/pillow">here</a> and <a href="http://stackoverflow.com/questions/tagged/pil">here</a>. Please <a href="https://github.com/python-pillow/Pillow/issues/new">report issues on GitHub</a>.
</p>
<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="ImageFilter.html" title="ImageFilter Module"
             >next</a> |</li>
        <li class="right" >
          <a href="ImageEnhance.html" title="ImageEnhance Module"
             >previous</a> |</li>
        <li><a href="../index.html">Home</a> &raquo;</li>
          <li><a href="index.html" >Reference</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 1997-2011 by Secret Labs AB, 1995-2011 by Fredrik Lundh, 2010-2013 Alex Clark.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>