Closed thouis closed 12 years ago
trac user nicopinto wrote on 2009-07-30
up!
@rgommers wrote on 2010-06-02
Is this with the official 1.6.1 PIL? I can't download your image anymore, but I can see it's uint8 or uint16 which is hopelessly broken in PIL. Maybe with the latest PIL trunk on Bitbucket you'll have more luck, or otherwise try scikits.image - it now has a FreeImage wrapper.
Leaving this open for now, but the chance of this being a numpy issue is quite small.
Milestone changed to Unscheduled
by @rgommers on 2010-06-02
trac user nicopinto wrote on 2010-06-02
Thanks for your answer. I'm using the official PIL 1.1.6.
To reproduce:
wget http://dl.dropbox.com/u/167753/spiky_adj_023.png && python -c "import numpy as np; import Image; print np.array(Image.open('spiky_adj_023.png'))"
and
wget http://dl.dropbox.com/u/167753/spiky_norm_001.png && python -c "import numpy as np; import Image; print np.array(Image.open('spiky_norm_001.png'))"
I get the same problem using the latest dev version of PIL.
@pv wrote on 2010-07-29
It's a bug in PIL, nothing we can fix:
>>> Image.open('spiky_norm_001.png').__array_interface__.keys()
['shape', 'data', 'typestr']
>>> Image.open('spiky_adj_023.png').__array_interface__.keys()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 507, in __getattr__
shape, typestr = _conv_type_shape(self)
File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 221, in _conv_type_shape
typ, extra = _MODE_CONV[im.mode]
KeyError: 'LA'
Original ticket http://projects.scipy.org/numpy/ticket/1179 on 2009-07-22 by trac user nicopinto, assigned to unknown.
For some reason I have a problem converting a specific png image using array().
Here is what I am getting (using numpy 1.3.0 and scipy 0.7.0).
% wget http://files.getdropbox.com/u/167753/spiky_adj_023.png % python -c "import numpy as np; import Image; print np.array(Image.open('spiky_adj_023.png'))"
<PngImagePlugin.PngImageFile instance at 0xd1a050>
% wget http://files.getdropbox.com/u/167753/spiky_norm_001.png % python -c "import numpy as np; import Image; print np.array(Image.open('spiky_norm_001.png'))" [[134 30 140 ..., 230 83 59] [ 99 202 233 ..., 160 63 133] [ 93 241 35 ..., 7 240 101] ..., [206 132 196 ..., 139 190 112] [218 21 217 ..., 121 152 109] [ 83 188 187 ..., 6 240 251]]
I was initially using scipy's misc.imread when I found this bug. I am currently using the following workaround: % python -c "import numpy as np; import Image; print np.array(Image.open('spiky_adj_023.png').convert('RGB'))"
Let me know what you think.