Skip to content

Commit 8989bc5

Browse files
committed
Update docs to talk about how we support Pillow, not PIL.
1 parent e6f8993 commit 8989bc5

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

INSTALL

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ libpng 1.2 (or later)
209209
using pip, easy_install or installing from source, the installer
210210
will attempt to download and install `pyparsing` from PyPI.
211211

212-
**Optional**
212+
**Optional dependencies**
213+
214+
`Pillow http://python-imaging.github.io/`__
215+
If Pillow is installed, matplotlib can read and write a larger
216+
selection of image file formats.
217+
218+
**Optional GUI frameworks**
213219

214220
These are optional packages which you may want to install to use
215221
matplotlib with a user interface toolkit. See

doc/faq/howto_faq.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,9 @@ or by saving to a file handle::
693693
import sys
694694
fig.savefig(sys.stdout)
695695

696-
Here is an example using the Python Imaging Library (PIL). First, the figure
697-
is saved to a StringIO object which is then fed to PIL for further
698-
processing::
696+
Here is an example using `Pillow <http://python-imaging.github.io/>__.
697+
First, the figure is saved to a StringIO object which is then fed to
698+
Pillow for further processing::
699699

700700
import StringIO, Image
701701
imgdata = StringIO.StringIO()

doc/users/image_tutorial.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ examples, if you use the -pylab method, you can skip the "mpimg." and
4040
Importing image data into Numpy arrays
4141
===============================================
4242

43-
Plotting image data is supported by the Python Image Library (`PIL
44-
<http://www.pythonware.com/products/pil/>`_). Natively, matplotlib
45-
only supports PNG images. The commands shown below fall back on PIL
46-
if the native read fails.
43+
Plotting image data is supported by the `Pillow
44+
<http://python-imaging.github.io/>`_). Natively, matplotlib only
45+
supports PNG images. The commands shown below fall back on Pillow if the
46+
native read fails.
4747

48-
The image used in this example is a PNG file, but keep that PIL
48+
The image used in this example is a PNG file, but keep that Pillow
4949
requirement in mind for your own data.
5050

5151
Here's the image we're going to play with:
@@ -116,13 +116,13 @@ And here we go...
116116

117117
Note the dtype there - float32. Matplotlib has rescaled the 8 bit
118118
data from each channel to floating point data between 0.0 and 1.0. As
119-
a side note, the only datatype that PIL can work with is uint8.
119+
a side note, the only datatype that Pillow can work with is uint8.
120120
Matplotlib plotting can handle float32 and uint8, but image
121121
reading/writing for any format other than PNG is limited to uint8
122122
data. Why 8 bits? Most displays can only render 8 bits per channel
123123
worth of color gradation. Why can they only render 8 bits/channel?
124124
Because that's about all the human eye can see. More here (from a
125-
photography standpoint): `Luminous Landscape bit depth tutorial
125+
photography standpoint): `Luminous Landscape bit depth tutorial
126126
<http://www.luminous-landscape.com/tutorials/bit-depth.shtml>`_.
127127

128128
Each inner list represents a pixel. Here, with an RGB image, there
@@ -179,7 +179,7 @@ channel of our data:
179179

180180
In [6]: lum_img = img[:,:,0]
181181

182-
This is array slicing. You can read more in the `Numpy tutorial
182+
This is array slicing. You can read more in the `Numpy tutorial
183183
<http://www.scipy.org/Tentative_NumPy_Tutorial>`_.
184184

185185
.. sourcecode:: ipython
@@ -336,9 +336,9 @@ and the computer has to draw in pixels to fill that space.
336336

337337
.. sourcecode:: ipython
338338

339-
In [8]: import Image
340-
In [9]: img = Image.open('stinkbug.png') # Open image as PIL image object
341-
In [10]: rsize = img.resize((img.size[0]/10,img.size[1]/10)) # Use PIL to resize
339+
In [8]: from PIL import Image
340+
In [9]: img = Image.open('stinkbug.png') # Open image as Pillow image object
341+
In [10]: rsize = img.resize((img.size[0]/10,img.size[1]/10)) # Use Pillow to resize
342342
In [11]: rsizeArr = np.asarray(rsize) # Get array back
343343
In [12]: imgplot = plt.imshow(rsizeArr)
344344

@@ -347,8 +347,8 @@ and the computer has to draw in pixels to fill that space.
347347
import matplotlib.pyplot as plt
348348
import matplotlib.image as mpimg
349349
import numpy as np
350-
import Image
351-
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
350+
from PIL import Image
351+
img = Image.open('../_static/stinkbug.png') # opens the file using Pillow - it's not an array yet
352352
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
353353
rsizeArr = np.asarray(rsize)
354354
lum_img = rsizeArr[:,:,0]
@@ -368,8 +368,8 @@ Let's try some others:
368368
import matplotlib.pyplot as plt
369369
import matplotlib.image as mpimg
370370
import numpy as np
371-
import Image
372-
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
371+
from PIL import Image
372+
img = Image.open('../_static/stinkbug.png') # opens the file using Pillow - it's not an array yet
373373
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
374374
rsizeArr = np.asarray(rsize)
375375
lum_img = rsizeArr[:,:,0]
@@ -385,8 +385,8 @@ Let's try some others:
385385
import matplotlib.pyplot as plt
386386
import matplotlib.image as mpimg
387387
import numpy as np
388-
import Image
389-
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
388+
from PIL import Image
389+
img = Image.open('../_static/stinkbug.png') # opens the file using Pillow - it's not an array yet
390390
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
391391
rsizeArr = np.asarray(rsize)
392392
lum_img = rsizeArr[:,:,0]

examples/pylab_examples/to_numeric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env python
22
"""
33
Use backend agg to access the figure canvas as an RGB string and then
4-
convert it to an array and pass the string it to PIL for
5-
rendering
4+
convert it to an array and pass the string it to Pillow for
5+
rendering.
66
"""
77

88
import pylab

0 commit comments

Comments
 (0)