[NumPy-Tickets] [NumPy] #1692: numpy.array segfaults on binary image from Python Imaging Library

NumPy Trac numpy-tickets@scipy....
Fri Dec 3 07:41:34 CST 2010


#1692: numpy.array segfaults on binary image from Python Imaging Library
--------------------+-------------------------------------------------------
 Reporter:  gerrit  |       Owner:  somebody
     Type:  defect  |      Status:  new     
 Priority:  normal  |   Milestone:  2.0.0   
Component:  Other   |     Version:  devel   
 Keywords:          |  
--------------------+-------------------------------------------------------
 When I try to convert a binary image loaded with the Python Imaging
 Library (version 1.1.7) using numpy (version 2.0.0.dev-12d0200), numpy
 segfaults. If I convert the image to 8-bit first, numpy can load it fine.

 {{{
 14:33:35:14414:gerrit@ubuntu10:~$ python
 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
 [GCC 4.4.5] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import Image, numpy
 >>> print Image.VERSION, numpy.version.version
 1.1.7 2.0.0.dev-12d0200
 >>> im = Image.open('/local/gerrit/benchmarking/images/lsm.png')
 >>> print im
 <PngImagePlugin.PngImageFile image mode=1 size=21601x10801 at 0x1B7BD40>
 >>> imd = numpy.array(im)
 Segmentation fault
 }}}

 If I convert the image to 8-bit first, there is no problem:

 {{{
 14:34:14:14414:gerrit@ubuntu10:~$ python
 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
 [GCC 4.4.5] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import Image, numpy
 >>> im = Image.open('/local/gerrit/benchmarking/images/lsm.png')
 >>> im = im.convert('L') # convert to 8-bit
 >>> print im
 <Image.Image image mode=L size=21601x10801 at 0x2C63488>
 >>> imd = numpy.array(im)
 >>> print imd
 [[  0   0   0 ...,   0   0   0]
  [  0   0   0 ...,   0   0   0]
  [  0   0   0 ...,   0   0   0]
  ...,
  [255 255 255 ..., 255 255 255]
  [255 255 255 ..., 255 255 255]
  [255 255 255 ..., 255 255 255]]
 }}}

 If I load a BMP instead of a PNG (also written by PIL), the same segfault
 occurs:

 {{{
 14:38:44:14416:gerrit@ubuntu10:~$ python
 Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
 [GCC 4.4.5] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import Image, numpy
 >>> im = Image.open('/local/gerrit/benchmarking/images/lsm.bmp')
 >>> print im
 <BmpImagePlugin.BmpImageFile image mode=1 size=21601x10801 at 0xDD5D40>
 >>> numpy.array(im)
 Segmentation fault
 }}}

 I have attached lsm.png (784 KiB).

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/1692>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list