You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have Python 2.7.5 on Mac OSX Mavericks with PIL 1.1.7 and I get the following when running the xkcd.py example:
Traceback (most recent call last):
File "xkcd.py", line 66, in <module>
for pix in i.tobytes():
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 512, in __getattr__
raise AttributeError(name)
AttributeError: tobytes
I was able to fix it by changing line 66 from:
for pix in i.tobytes():
to
for pix in i.tostring():
I found it with some help from this stackoverflow question. It seems like the official PIL 1.1.7 still uses the tostring method while Pillow is deprecating it in favor of tobytes (although it still supports the old one).
A simple approach to deal with this could be to just test the attribute first:
try:
i_converted = i.tobytes()
except AttributeError:
i_converted = i.tostring()
for pix in i_converted:
(...)
The text was updated successfully, but these errors were encountered:
I have Python 2.7.5 on Mac OSX Mavericks with PIL 1.1.7 and I get the following when running the xkcd.py example:
I was able to fix it by changing line 66 from:
to
I found it with some help from this stackoverflow question. It seems like the official PIL 1.1.7 still uses the tostring method while Pillow is deprecating it in favor of tobytes (although it still supports the old one).
A simple approach to deal with this could be to just test the attribute first:
The text was updated successfully, but these errors were encountered: