Skip to content

PIL -> Pillow #2137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion INSTALL
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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