<!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>ImagePath Module — 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="ImageQt Module" href="ImageQt.html" /> <link rel="prev" title="ImagePalette Module" href="ImagePalette.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="ImageQt.html" title="ImageQt Module" accesskey="N">next</a> |</li> <li class="right" > <a href="ImagePalette.html" title="ImagePalette Module" accesskey="P">previous</a> |</li> <li><a href="../index.html">Home</a> »</li> <li><a href="index.html" accesskey="U">Reference</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <span class="target" id="module-PIL.ImagePath"></span><div class="section" id="imagepath-module"> <h1><tt class="xref py py-mod docutils literal"><span class="pre">ImagePath</span></tt> Module<a class="headerlink" href="#imagepath-module" title="Permalink to this headline">¶</a></h1> <p>The <tt class="xref py py-mod docutils literal"><span class="pre">ImagePath</span></tt> module is used to store and manipulate 2-dimensional vector data. Path objects can be passed to the methods on the <a class="reference internal" href="ImageDraw.html#module-PIL.ImageDraw" title="PIL.ImageDraw"><tt class="xref py py-mod docutils literal"><span class="pre">ImageDraw</span></tt></a> module.</p> <dl class="class"> <dt id="PIL.ImagePath.PIL.ImagePath.Path"> <em class="property">class </em><tt class="descclassname">PIL.ImagePath.</tt><tt class="descname">Path</tt><a class="headerlink" href="#PIL.ImagePath.PIL.ImagePath.Path" title="Permalink to this definition">¶</a></dt> <dd><p>A path object. The coordinate list can be any sequence object containing either 2-tuples [(x, y), …] or numeric values [x, y, …].</p> <p>You can also create a path object from another path object.</p> <p>In 1.1.6 and later, you can also pass in any object that implements Python’s buffer API. The buffer should provide read access, and contain C floats in machine byte order.</p> <p>The path object implements most parts of the Python sequence interface, and behaves like a list of (x, y) pairs. You can use len(), item access, and slicing as usual. However, the current version does not support slice assignment, or item and slice deletion.</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">Parameters:</th><td class="field-body"><strong>xy</strong> – A sequence. The sequence can contain 2-tuples [(x, y), ...] or a flat list of numbers [x, y, ...].</td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="PIL.ImagePath.PIL.ImagePath.Path.compact"> <tt class="descclassname">PIL.ImagePath.Path.</tt><tt class="descname">compact</tt><big>(</big><em>distance=2</em><big>)</big><a class="headerlink" href="#PIL.ImagePath.PIL.ImagePath.Path.compact" title="Permalink to this definition">¶</a></dt> <dd><p>Compacts the path, by removing points that are close to each other. This method modifies the path in place, and returns the number of points left in the path.</p> <p><strong>distance</strong> is measured as <a class="reference external" href="http://en.wikipedia.org/wiki/Manhattan_distance">Manhattan distance</a> and defaults to two pixels.</p> </dd></dl> <dl class="method"> <dt id="PIL.ImagePath.PIL.ImagePath.Path.getbbox"> <tt class="descclassname">PIL.ImagePath.Path.</tt><tt class="descname">getbbox</tt><big>(</big><big>)</big><a class="headerlink" href="#PIL.ImagePath.PIL.ImagePath.Path.getbbox" title="Permalink to this definition">¶</a></dt> <dd><p>Gets the bounding box of the path.</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">Returns:</th><td class="field-body"><tt class="docutils literal"><span class="pre">(x0,</span> <span class="pre">y0,</span> <span class="pre">x1,</span> <span class="pre">y1)</span></tt></td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="PIL.ImagePath.PIL.ImagePath.Path.map"> <tt class="descclassname">PIL.ImagePath.Path.</tt><tt class="descname">map</tt><big>(</big><em>function</em><big>)</big><a class="headerlink" href="#PIL.ImagePath.PIL.ImagePath.Path.map" title="Permalink to this definition">¶</a></dt> <dd><p>Maps the path through a function.</p> </dd></dl> <dl class="method"> <dt id="PIL.ImagePath.PIL.ImagePath.Path.tolist"> <tt class="descclassname">PIL.ImagePath.Path.</tt><tt class="descname">tolist</tt><big>(</big><em>flat=0</em><big>)</big><a class="headerlink" href="#PIL.ImagePath.PIL.ImagePath.Path.tolist" title="Permalink to this definition">¶</a></dt> <dd><p>Converts the path to a Python list [(x, y), …].</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">Parameters:</th><td class="field-body"><strong>flat</strong> – By default, this function returns a list of 2-tuples [(x, y), ...]. If this argument is <tt class="xref std std-keyword docutils literal"><span class="pre">True</span></tt>, it returns a flat list [x, y, ...] instead.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">A list of coordinates. See <strong>flat</strong>.</td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="PIL.ImagePath.PIL.ImagePath.Path.transform"> <tt class="descclassname">PIL.ImagePath.Path.</tt><tt class="descname">transform</tt><big>(</big><em>matrix</em><big>)</big><a class="headerlink" href="#PIL.ImagePath.PIL.ImagePath.Path.transform" title="Permalink to this definition">¶</a></dt> <dd><p>Transforms the path in place, using an affine transform. The matrix is a 6-tuple (a, b, c, d, e, f), and each point is mapped as follows:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">xOut</span> <span class="o">=</span> <span class="n">xIn</span> <span class="o">*</span> <span class="n">a</span> <span class="o">+</span> <span class="n">yIn</span> <span class="o">*</span> <span class="n">b</span> <span class="o">+</span> <span class="n">c</span> <span class="n">yOut</span> <span class="o">=</span> <span class="n">xIn</span> <span class="o">*</span> <span class="n">d</span> <span class="o">+</span> <span class="n">yIn</span> <span class="o">*</span> <span class="n">e</span> <span class="o">+</span> <span class="n">f</span> </pre></div> </div> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/reference/ImagePath.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="ImageQt.html" title="ImageQt Module" >next</a> |</li> <li class="right" > <a href="ImagePalette.html" title="ImagePalette Module" >previous</a> |</li> <li><a href="../index.html">Home</a> »</li> <li><a href="index.html" >Reference</a> »</li> </ul> </div> <div class="footer"> © 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>