We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0bbff96 commit 7f47001Copy full SHA for 7f47001
examples/pylab_examples/agg_buffer.py
@@ -4,6 +4,8 @@
4
convert it to an array and pass it to Pillow for rendering.
5
"""
6
7
+import numpy as np
8
+
9
import matplotlib.pyplot as plt
10
from matplotlib.backends.backend_agg import FigureCanvasAgg
11
@@ -28,7 +30,10 @@
28
30
X = np.fromstring(s, np.uint8)
29
31
X.shape = h, w, 3
32
-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)
37
38
# Uncomment this line to display the image using ImageMagick's
39
# `display` tool.
0 commit comments