Skip to content

Commit

Permalink
Merge pull request #2137 from mdboom/doc/pil-version
Browse files Browse the repository at this point in the history
PIL -> Pillow
  • Loading branch information
tacaswell committed Jan 22, 2014
2 parents e6f8993 + a607350 commit db49c9c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
8 changes: 7 additions & 1 deletion INSTALL
Expand Up @@ -209,7 +209,13 @@ libpng 1.2 (or later)
using pip, easy_install or installing from source, the installer
will attempt to download and install `pyparsing` from PyPI.

**Optional**
**Optional dependencies**

`Pillow http://python-imaging.github.io/`__
If Pillow is installed, matplotlib can read and write a larger
selection of image file formats.

**Optional GUI frameworks**

These are optional packages which you may want to install to use
matplotlib with a user interface toolkit. See
Expand Down
6 changes: 3 additions & 3 deletions doc/faq/howto_faq.rst
Expand Up @@ -693,9 +693,9 @@ or by saving to a file handle::
import sys
fig.savefig(sys.stdout)

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

import StringIO, Image
imgdata = StringIO.StringIO()
Expand Down
34 changes: 17 additions & 17 deletions doc/users/image_tutorial.rst
Expand Up @@ -40,12 +40,12 @@ examples, if you use the -pylab method, you can skip the "mpimg." and
Importing image data into Numpy arrays
===============================================

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

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

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

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

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

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

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

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

.. sourcecode:: ipython

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

Expand All @@ -347,8 +347,8 @@ and the computer has to draw in pixels to fill that space.
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import Image
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
from PIL import Image
img = Image.open('../_static/stinkbug.png') # opens the file using Pillow - it's not an array yet
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
rsizeArr = np.asarray(rsize)
lum_img = rsizeArr[:,:,0]
Expand All @@ -368,8 +368,8 @@ Let's try some others:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import Image
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
from PIL import Image
img = Image.open('../_static/stinkbug.png') # opens the file using Pillow - it's not an array yet
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
rsizeArr = np.asarray(rsize)
lum_img = rsizeArr[:,:,0]
Expand All @@ -385,8 +385,8 @@ Let's try some others:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import Image
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
from PIL import Image
img = Image.open('../_static/stinkbug.png') # opens the file using Pillow - it's not an array yet
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
rsizeArr = np.asarray(rsize)
lum_img = rsizeArr[:,:,0]
Expand Down
3 changes: 1 addition & 2 deletions examples/pylab_examples/to_numeric.py
@@ -1,8 +1,7 @@
#!/usr/bin/env python
"""
Use backend agg to access the figure canvas as an RGB string and then
convert it to an array and pass the string it to PIL for
rendering
convert it to an array and pass it to Pillow for rendering.
"""

import pylab
Expand Down

0 comments on commit db49c9c

Please sign in to comment.