diff --git a/INSTALL b/INSTALL index ebcb79493866..4a169d387b0b 100644 --- a/INSTALL +++ b/INSTALL @@ -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 diff --git a/doc/faq/howto_faq.rst b/doc/faq/howto_faq.rst index d3cf31e515c4..87be81e33fc9 100644 --- a/doc/faq/howto_faq.rst +++ b/doc/faq/howto_faq.rst @@ -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 __. +First, the figure is saved to a StringIO object which is then fed to +Pillow for further processing:: import StringIO, Image imgdata = StringIO.StringIO() diff --git a/doc/users/image_tutorial.rst b/doc/users/image_tutorial.rst index dbc74d66ea79..646c13e1f377 100644 --- a/doc/users/image_tutorial.rst +++ b/doc/users/image_tutorial.rst @@ -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 -`_). 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 +`_). 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: @@ -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 `_. Each inner list represents a pixel. Here, with an RGB image, there @@ -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 `_. .. sourcecode:: ipython @@ -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) @@ -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] @@ -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] @@ -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] diff --git a/examples/pylab_examples/to_numeric.py b/examples/pylab_examples/to_numeric.py index bb30bf73f00b..eaac80ed8ecd 100755 --- a/examples/pylab_examples/to_numeric.py +++ b/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