Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > b17ed897c34853a0a39ef25ab5d3af32 > files > 117

python3-pillow-doc-2.6.2-2.mga5.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>Image 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="ImageChops (“Channel Operations”) Module" href="ImageChops.html" />
    <link rel="prev" title="Reference" href="index.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="ImageChops.html" title="ImageChops (“Channel Operations”) Module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Reference"
             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.Image"></span><div class="section" id="image-module">
<h1><tt class="xref py py-mod docutils literal"><span class="pre">Image</span></tt> Module<a class="headerlink" href="#image-module" title="Permalink to this headline">¶</a></h1>
<p>The <a class="reference internal" href="#module-PIL.Image" title="PIL.Image"><tt class="xref py py-mod docutils literal"><span class="pre">Image</span></tt></a> module provides a class with the same name which is
used to represent a PIL image. The module also provides a number of factory
functions, including functions to load images from files, and to create new
images.</p>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<p>The following script loads an image, rotates it 45 degrees, and displays it
using an external viewer (usually xv on Unix, and the paint program on
Windows).</p>
<div class="section" id="open-rotate-and-display-an-image-using-the-default-viewer">
<h3>Open, rotate, and display an image (using the default viewer)<a class="headerlink" href="#open-rotate-and-display-an-image-using-the-default-viewer" title="Permalink to this headline">¶</a></h3>
<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">Image</span>
<span class="n">im</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s">&quot;bride.jpg&quot;</span><span class="p">)</span>
<span class="n">im</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span><span class="o">.</span><span class="n">show</span><span class="p">()</span>
</pre></div>
</div>
<p>The following script creates nice 128x128 thumbnails of all JPEG images in the
current directory.</p>
</div>
<div class="section" id="create-thumbnails">
<h3>Create thumbnails<a class="headerlink" href="#create-thumbnails" title="Permalink to this headline">¶</a></h3>
<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">Image</span>
<span class="kn">import</span> <span class="nn">glob</span><span class="o">,</span> <span class="nn">os</span>

<span class="n">size</span> <span class="o">=</span> <span class="mi">128</span><span class="p">,</span> <span class="mi">128</span>

<span class="k">for</span> <span class="n">infile</span> <span class="ow">in</span> <span class="n">glob</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s">&quot;*.jpg&quot;</span><span class="p">):</span>
    <span class="nb">file</span><span class="p">,</span> <span class="n">ext</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">splitext</span><span class="p">(</span><span class="n">infile</span><span class="p">)</span>
    <span class="n">im</span> <span class="o">=</span> <span class="n">Image</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">infile</span><span class="p">)</span>
    <span class="n">im</span><span class="o">.</span><span class="n">thumbnail</span><span class="p">(</span><span class="n">size</span><span class="p">,</span> <span class="n">Image</span><span class="o">.</span><span class="n">ANTIALIAS</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="nb">file</span> <span class="o">+</span> <span class="s">&quot;.thumbnail&quot;</span><span class="p">,</span> <span class="s">&quot;JPEG&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2>
<div class="section" id="image-processing">
<h3>Image processing<a class="headerlink" href="#image-processing" title="Permalink to this headline">¶</a></h3>
</div>
<div class="section" id="constructing-images">
<h3>Constructing images<a class="headerlink" href="#constructing-images" title="Permalink to this headline">¶</a></h3>
</div>
<div class="section" id="registering-plugins">
<h3>Registering plugins<a class="headerlink" href="#registering-plugins" title="Permalink to this headline">¶</a></h3>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">These functions are for use by plugin authors. Application authors can
ignore them.</p>
</div>
</div>
</div>
<div class="section" id="the-image-class">
<h2>The Image Class<a class="headerlink" href="#the-image-class" title="Permalink to this headline">¶</a></h2>
<p>An instance of the <tt class="xref py py-class docutils literal"><span class="pre">Image</span></tt> class has the following
methods. Unless otherwise stated, all methods return a new instance of the
<tt class="xref py py-class docutils literal"><span class="pre">Image</span></tt> class, holding the resulting image.</p>
<p>The following example converts an RGB image (linearly calibrated according to
ITU-R 709, using the D65 luminant) to the CIE XYZ color space:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">rgb2xyz</span> <span class="o">=</span> <span class="p">(</span>
    <span class="mf">0.412453</span><span class="p">,</span> <span class="mf">0.357580</span><span class="p">,</span> <span class="mf">0.180423</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span>
    <span class="mf">0.212671</span><span class="p">,</span> <span class="mf">0.715160</span><span class="p">,</span> <span class="mf">0.072169</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span>
    <span class="mf">0.019334</span><span class="p">,</span> <span class="mf">0.119193</span><span class="p">,</span> <span class="mf">0.950227</span><span class="p">,</span> <span class="mi">0</span> <span class="p">)</span>
<span class="n">out</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">convert</span><span class="p">(</span><span class="s">&quot;RGB&quot;</span><span class="p">,</span> <span class="n">rgb2xyz</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="attributes">
<h2>Attributes<a class="headerlink" href="#attributes" title="Permalink to this headline">¶</a></h2>
<p>Instances of the <tt class="xref py py-class docutils literal"><span class="pre">Image</span></tt> class have the following attributes:</p>
<dl class="attribute">
<dt id="PIL.Image.format">
<tt class="descclassname">PIL.Image.</tt><tt class="descname">format</tt><a class="headerlink" href="#PIL.Image.format" title="Permalink to this definition">¶</a></dt>
<dd><p>The file format of the source file. For images created by the library
itself (via a factory function, or by running a method on an existing
image), this attribute is set to <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body"><tt class="xref py py-class docutils literal"><span class="pre">string</span></tt> or <tt class="docutils literal"><span class="pre">None</span></tt></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="PIL.Image.mode">
<tt class="descclassname">PIL.Image.</tt><tt class="descname">mode</tt><a class="headerlink" href="#PIL.Image.mode" title="Permalink to this definition">¶</a></dt>
<dd><p>Image mode. This is a string specifying the pixel format used by the image.
Typical values are “1”, “L”, “RGB”, or “CMYK.” See
<a class="reference internal" href="../handbook/concepts.html"><em>Concepts</em></a> for a full list.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body"><tt class="xref py py-class docutils literal"><span class="pre">string</span></tt></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="PIL.Image.size">
<tt class="descclassname">PIL.Image.</tt><tt class="descname">size</tt><a class="headerlink" href="#PIL.Image.size" title="Permalink to this definition">¶</a></dt>
<dd><p>Image size, in pixels. The size is given as a 2-tuple (width, height).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body"><tt class="docutils literal"><span class="pre">(width,</span> <span class="pre">height)</span></tt></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="PIL.Image.palette">
<tt class="descclassname">PIL.Image.</tt><tt class="descname">palette</tt><a class="headerlink" href="#PIL.Image.palette" title="Permalink to this definition">¶</a></dt>
<dd><p>Colour palette table, if any. If mode is “P”, this should be an instance of
the <tt class="xref py py-class docutils literal"><span class="pre">ImagePalette</span></tt> class. Otherwise, it should
be set to <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body"><tt class="xref py py-class docutils literal"><span class="pre">ImagePalette</span></tt> or <tt class="docutils literal"><span class="pre">None</span></tt></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="PIL.Image.info">
<tt class="descclassname">PIL.Image.</tt><tt class="descname">info</tt><a class="headerlink" href="#PIL.Image.info" title="Permalink to this definition">¶</a></dt>
<dd><p>A dictionary holding data associated with the image. This dictionary is
used by file handlers to pass on various non-image information read from
the file. See documentation for the various file handlers for details.</p>
<p>Most methods ignore the dictionary when returning new images; since the
keys are not standardized, it’s not possible for a method to know if the
operation affects the dictionary. If you need the information later on,
keep a reference to the info dictionary returned from the open method.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Type:</th><td class="field-body"><a class="reference external" href="http://docs.python.org/2/library/stdtypes.html#dict" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a></td>
</tr>
</tbody>
</table>
</dd></dl>

</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">Image</span></tt> Module</a><ul>
<li><a class="reference internal" href="#examples">Examples</a><ul>
<li><a class="reference internal" href="#open-rotate-and-display-an-image-using-the-default-viewer">Open, rotate, and display an image (using the default viewer)</a></li>
<li><a class="reference internal" href="#create-thumbnails">Create thumbnails</a></li>
</ul>
</li>
<li><a class="reference internal" href="#functions">Functions</a><ul>
<li><a class="reference internal" href="#image-processing">Image processing</a></li>
<li><a class="reference internal" href="#constructing-images">Constructing images</a></li>
<li><a class="reference internal" href="#registering-plugins">Registering plugins</a></li>
</ul>
</li>
<li><a class="reference internal" href="#the-image-class">The Image Class</a></li>
<li><a class="reference internal" href="#attributes">Attributes</a></li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/reference/Image.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="ImageChops.html" title="ImageChops (“Channel Operations”) Module"
             >next</a> |</li>
        <li class="right" >
          <a href="index.html" title="Reference"
             >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-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>