Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f47001

Browse filesBrowse files
committed
Fix exception with Pillow 3
Image.fromstring was removed in Pillow 3.0. Also added missing numpy import.
1 parent 0bbff96 commit 7f47001
Copy full SHA for 7f47001

File tree

Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed

‎examples/pylab_examples/agg_buffer.py

Copy file name to clipboardExpand all lines: examples/pylab_examples/agg_buffer.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
convert it to an array and pass it to Pillow for rendering.
55
"""
66

7+
import numpy as np
8+
79
import matplotlib.pyplot as plt
810
from matplotlib.backends.backend_agg import FigureCanvasAgg
911

@@ -28,7 +30,10 @@
2830
X = np.fromstring(s, np.uint8)
2931
X.shape = h, w, 3
3032

31-
im = Image.fromstring("RGB", (w, h), s)
33+
try:
34+
im = Image.fromstring("RGB", (w, h), s)
35+
except Exception:
36+
im = Image.frombytes("RGB", (w, h), s)
3237

3338
# Uncomment this line to display the image using ImageMagick's
3439
# `display` tool.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.