This file is indexed.

/usr/share/doc/python-willow/html/reference.html is in python-willow-doc 1.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Reference &mdash; Willow 1.1 documentation</title>
  

  
  
  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  

  

  
        <link rel="index" title="Index"
              href="genindex.html"/>
        <link rel="search" title="Search" href="search.html"/>
    <link rel="top" title="Willow 1.1 documentation" href="index.html"/>
        <link rel="next" title="Changelog" href="changelog.html"/>
        <link rel="prev" title="Extending Willow" href="guide/extend.html"/> 

  
  <script src="_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="index.html" class="icon icon-home"> Willow
          

          
          </a>

          
            
            
              <div class="version">
                1.1
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="concepts.html">Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="guide/index.html">Usage guide</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Willow</a>
        
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>Reference</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/reference.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="reference">
<h1>Reference<a class="headerlink" href="#reference" title="Permalink to this headline"></a></h1>
<div class="section" id="the-image-class">
<h2>The <code class="docutils literal"><span class="pre">Image</span></code> class<a class="headerlink" href="#the-image-class" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="Image">
<em class="property">class </em><code class="descname">Image</code><a class="headerlink" href="#Image" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="classmethod">
<dt id="open">
<em class="property">classmethod </em><code class="descname">open</code><span class="sig-paren">(</span><em>file</em><span class="sig-paren">)</span><a class="headerlink" href="#open" title="Permalink to this definition"></a></dt>
<dd><p>Opens the provided image file detects the format from the image header using
Python’s <code class="xref py py-mod docutils literal"><span class="pre">imghdr</span></code> module.</p>
<p>Returns a subclass of <code class="xref py py-class docutils literal"><span class="pre">ImageFile</span></code></p>
<p>If the image format is unrecognised, this throws a <code class="xref py py-class docutils literal"><span class="pre">willow.image.UnrecognisedImageFormatError</span></code>
(a subclass of <code class="xref py py-class docutils literal"><span class="pre">IOError</span></code>)</p>
</dd></dl>

<dl class="classmethod">
<dt id="operation">
<em class="property">classmethod </em><code class="descname">operation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#operation" title="Permalink to this definition"></a></dt>
<dd><p>A decorator for registering operations.</p>
<p>The operations will be automatically registered when the image class is registered.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">willow.image</span> <span class="kn">import</span> <span class="n">Image</span>

<span class="k">class</span> <span class="nc">MyImage</span><span class="p">(</span><span class="n">Image</span><span class="p">):</span>

    <span class="nd">@Image.operation</span>
    <span class="k">def</span> <span class="nf">resize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">MyImage</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">size</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="classmethod">
<dt id="converter_from">
<em class="property">classmethod </em><code class="descname">converter_from</code><span class="sig-paren">(</span><em>other_classes</em>, <em>cost=100</em><span class="sig-paren">)</span><a class="headerlink" href="#converter_from" title="Permalink to this definition"></a></dt>
<dd><p>A decorator for registering a “from” converter, which is a classmethod that
converts an instance of another image class into an instance of this one.</p>
<p>The <code class="docutils literal"><span class="pre">other_classes</span></code> parameter specifies which classes this converter can
convert from. It can be a single class or a list.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">willow.image</span> <span class="kn">import</span> <span class="n">Image</span>

<span class="k">class</span> <span class="nc">MyImage</span><span class="p">(</span><span class="n">Image</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="nd">@classmethod</span>
    <span class="nd">@Image.converter_from</span><span class="p">(</span><span class="n">JPEGImageFile</span><span class="p">)</span>
    <span class="k">def</span> <span class="nf">open_jpeg_file</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">image_file</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">image</span><span class="o">=</span><span class="n">open_jpeg</span><span class="p">(</span><span class="n">image_file</span><span class="o">.</span><span class="n">f</span><span class="p">))</span>
</pre></div>
</div>
<p>It can also be applied multiple times to the same function allowing different
costs to be specified for different classes:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="nd">@classmethod</span>
<span class="nd">@Image.converter_from</span><span class="p">([</span><span class="n">JPEGImageFile</span><span class="p">,</span> <span class="n">PNGImageFile</span><span class="p">])</span>
<span class="nd">@Image.converter_from</span><span class="p">(</span><span class="n">GIFImageFile</span><span class="p">,</span> <span class="n">cost</span><span class="o">=</span><span class="mi">200</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">open_file</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">image_file</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
</dd></dl>

<dl class="classmethod">
<dt id="converter_to">
<em class="property">classmethod </em><code class="descname">converter_to</code><span class="sig-paren">(</span><em>other_class</em>, <em>cost=100</em><span class="sig-paren">)</span><a class="headerlink" href="#converter_to" title="Permalink to this definition"></a></dt>
<dd><p>A decorator for registering a “to” converter, which is a method that converts
this image into an instance of another class.</p>
<p>The <code class="docutils literal"><span class="pre">other_class</span></code> parameter specifies which class this function converts to.
An individual “to” converter can only convert to a single class.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">willow.image</span> <span class="kn">import</span> <span class="n">Image</span>

<span class="k">class</span> <span class="nc">MyImage</span><span class="p">(</span><span class="n">Image</span><span class="p">):</span>
    <span class="o">...</span>

    <span class="nd">@Image.converter_to</span><span class="p">(</span><span class="n">PillowImage</span><span class="p">)</span>
    <span class="k">def</span> <span class="nf">convert_to_pillow</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">image</span> <span class="o">=</span> <span class="n">PIL</span><span class="o">.</span><span class="n">Image</span><span class="p">()</span>  <span class="c1"># Code to create PIL image object here</span>
        <span class="k">return</span> <span class="n">PillowImage</span><span class="p">(</span><span class="n">image</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="builtin-operations">
<h2>Builtin operations<a class="headerlink" href="#builtin-operations" title="Permalink to this headline"></a></h2>
<p>Here’s a full list of operations provided by Willow out of the box:</p>
<dl class="method">
<dt id="get_size">
<code class="descname">get_size</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#get_size" title="Permalink to this definition"></a></dt>
<dd><p>Returns the size of the image as a tuple of two integers:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">width</span><span class="p">,</span> <span class="n">height</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">get_size</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="has_alpha">
<code class="descname">has_alpha</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#has_alpha" title="Permalink to this definition"></a></dt>
<dd><p>Returns <code class="docutils literal"><span class="pre">True</span></code> if the image has an alpha channel.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">image</span><span class="o">.</span><span class="n">has_alpha</span><span class="p">():</span>
    <span class="c1"># Image has alpha</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="has_animation">
<code class="descname">has_animation</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#has_animation" title="Permalink to this definition"></a></dt>
<dd><p>Returns <code class="docutils literal"><span class="pre">True</span></code> if the image is animated.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">image</span><span class="o">.</span><span class="n">has_animation</span><span class="p">():</span>
    <span class="c1"># Image has animation</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="resize">
<code class="descname">resize</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="headerlink" href="#resize" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>Stretches the image to fit the specified size. Size must be a sequence of two integers:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Resize the image to 100x100 pixels</span>
<span class="n">resized_image</span> <span class="o">=</span> <span class="n">source_image</span><span class="o">.</span><span class="n">resize</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="crop">
<code class="descname">crop</code><span class="sig-paren">(</span><em>region</em><span class="sig-paren">)</span><a class="headerlink" href="#crop" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>Cuts out the specified region of the image. The region must be a sequence of
four integers (top, left, right, bottom):</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Cut out a square from the middle of the image</span>
<span class="n">cropped_image</span> <span class="o">=</span> <span class="n">source_image</span><span class="o">.</span><span class="n">resize</span><span class="p">((</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">200</span><span class="p">,</span> <span class="mi">200</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="set_background_color_rgb">
<code class="descname">set_background_color_rgb</code><span class="sig-paren">(</span><em>color</em><span class="sig-paren">)</span><a class="headerlink" href="#set_background_color_rgb" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>If the image has an alpha channel, this will add a background colour using
the alpha channel as a mask. The alpha channel will be removed from the
resulting image.</p>
<p>The background colour must be specified as a tuple of three integers with
values between 0 - 255.</p>
<p>This operation will convert the image to RGB format, but will not do
anything if there is not an alpha channel.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># Set the background colour of the image to white</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">source_image</span><span class="o">.</span><span class="n">set_background_color_rgb</span><span class="p">((</span><span class="mi">255</span><span class="p">,</span> <span class="mi">255</span><span class="p">,</span> <span class="mi">255</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="auto_orient">
<code class="descname">auto_orient</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#auto_orient" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>Some JPEG files have orientation data in an EXIF tag that needs to be applied
to the image. This method applies this orientation to the image (it is a no-op
for other image formats).</p>
<p>This should be run before performing any other image operations.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">image</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">auto_orient</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="detect_features">
<code class="descname">detect_features</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#detect_features" title="Permalink to this definition"></a></dt>
<dd><p>(OpenCV only)</p>
<p>Uses OpenCV to find the most prominent corners in the image.
Useful for detecting interesting features for cropping against.</p>
<p>Returns a list of two integer tuples containing the coordinates of each
point on the image</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">points</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">detect_features</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="detect_faces">
<code class="descname">detect_faces</code><span class="sig-paren">(</span><em>cascade_filename</em><span class="sig-paren">)</span><a class="headerlink" href="#detect_faces" title="Permalink to this definition"></a></dt>
<dd><p>(OpenCV only)</p>
<p>Uses OpenCV’s <a class="reference external" href="http://docs.opencv.org/2.4/modules/objdetect/doc/cascade_classification.html">cascade classification</a>
to detect faces in the image.</p>
<p>By default the <code class="docutils literal"><span class="pre">haarcascade_frontalface_alt2.xml</span></code> (provided by OpenCV)
cascade file is used. You can specifiy the filename to a different cascade
file in the first parameter.</p>
<p>Returns a list of four integer tuples containing the left, top, right, bottom
locations of each face detected in the image.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">faces</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">detect_faces</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="save_as_jpeg">
<code class="descname">save_as_jpeg</code><span class="sig-paren">(</span><em>file</em>, <em>quality=85</em>, <em>optimize=False</em><span class="sig-paren">)</span><a class="headerlink" href="#save_as_jpeg" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>Saves the image to the specified file-like object in JPEG format.</p>
<p>Note: If the image has an alpha channel, this operation may raise an
exception or save a broken image (depending on the backend being used).
To resolve this, use the <code class="xref py py-meth docutils literal"><span class="pre">set_background_color_rgb()</span></code> method to
replace the alpha channel with a solid background color before saving as JPEG.</p>
<p>Returns a <code class="docutils literal"><span class="pre">JPEGImageFile</span></code> wrapping the file.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;out.jpg&#39;</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">image</span><span class="o">.</span><span class="n">save_as_jpeg</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="save_as_png">
<code class="descname">save_as_png</code><span class="sig-paren">(</span><em>file</em>, <em>optimize=False</em><span class="sig-paren">)</span><a class="headerlink" href="#save_as_png" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>Saves the image to the specified file-like object in PNG format.</p>
<p>Returns a <code class="docutils literal"><span class="pre">PNGImageFile</span></code> wrapping the file.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;out.png&#39;</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">image</span><span class="o">.</span><span class="n">save_as_png</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="save_as_gif">
<code class="descname">save_as_gif</code><span class="sig-paren">(</span><em>file</em><span class="sig-paren">)</span><a class="headerlink" href="#save_as_gif" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow/Wand only)</p>
<p>Saves the image to the specified file-like object in GIF format.</p>
<p>returns a <code class="docutils literal"><span class="pre">GIFImageFile</span></code> wrapping the file.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;out.gif&#39;</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">image</span><span class="o">.</span><span class="n">save_as_gif</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="get_pillow_image">
<code class="descname">get_pillow_image</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#get_pillow_image" title="Permalink to this definition"></a></dt>
<dd><p>(Pillow only)</p>
<p>Returns a <code class="docutils literal"><span class="pre">PIL.Image</span></code> object for the specified image. This may be useful
for reusing existing code that requires a Pillow image.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">do_thing</span><span class="p">(</span><span class="n">image</span><span class="o">.</span><span class="n">get_pillow_image</span><span class="p">())</span>
</pre></div>
</div>
<p>You can convert a <code class="docutils literal"><span class="pre">PIL.Image</span></code> object back into a Willow <a class="reference internal" href="#Image" title="Image"><code class="xref py py-class docutils literal"><span class="pre">Image</span></code></a>
using the <code class="docutils literal"><span class="pre">PillowImage</span></code> class:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">PIL.Image</span>
<span class="kn">from</span> <span class="nn">willow.plugins.pillow</span> <span class="kn">import</span> <span class="n">PillowImage</span>

<span class="n">pillow_image</span> <span class="o">=</span> <span class="n">PIL</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="s1">&#39;test.jpg&#39;</span><span class="p">)</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">PillowImage</span><span class="p">(</span><span class="n">pillow_image</span><span class="p">)</span>

<span class="c1"># Now you can use any Willow operation on that image</span>
<span class="n">faces</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">detect_faces</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="get_wand_image">
<code class="descname">get_wand_image</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#get_wand_image" title="Permalink to this definition"></a></dt>
<dd><p>(Wand only)</p>
<p>Returns a <code class="docutils literal"><span class="pre">Wand.Image</span></code> object for the specified image. This may be useful
for reusing existing code that requires a Wand image.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="n">do_thing</span><span class="p">(</span><span class="n">image</span><span class="o">.</span><span class="n">get_wand_image</span><span class="p">())</span>
</pre></div>
</div>
<p>You can convert a <code class="docutils literal"><span class="pre">Wand.Image</span></code> object back into a Willow <a class="reference internal" href="#Image" title="Image"><code class="xref py py-class docutils literal"><span class="pre">Image</span></code></a>
using the <code class="docutils literal"><span class="pre">WandImage</span></code> class:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">wand.image</span> <span class="kn">import</span> <span class="n">Image</span>
<span class="kn">from</span> <span class="nn">willow.plugins.wand</span> <span class="kn">import</span> <span class="n">WandImage</span>

<span class="c1"># wand_image is an instance of Wand.Image</span>
<span class="n">wand_image</span> <span class="o">=</span> <span class="n">Image</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="s1">&#39;pikachu.png&#39;</span><span class="p">)</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">WandImage</span><span class="p">(</span><span class="n">wand_image</span><span class="p">)</span>

<span class="c1"># Now you can use any Willow operation on that image</span>
<span class="n">faces</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">detect_faces</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>


           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="changelog.html" class="btn btn-neutral float-right" title="Changelog" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="guide/extend.html" class="btn btn-neutral" title="Extending Willow" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Torchbox.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'./',
            VERSION:'1.1',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </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/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>