[Image-SIG] PIL throws exception when reading 8bit greyscale bitmap and pnm data

Cameron Walsh cameron.walsh at gmail.com
Fri Dec 1 02:30:58 CET 2006


On 30/11/06, Cameron Walsh <cameron.walsh at gmail.com> wrote:
> Hi all,
>
> I'm trying to extract the data from a bitmap or .pnm file using the
> following code:
>
> import Image
> img = Image.open("test.bmp","r")
> data=img.getdata()
>
> Unfortunately I get the following exception on Linux, but not on Windows:
>
> >>> data=img.getdata()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 796,
> in getdata
>     self.load()
>   File "/usr/local/lib/python2.5/site-packages/PIL/ImageFile.py", line
> 147, in load
>     self.map = mmap.mmap(file.fileno(), size)
> EnvironmentError: [Errno 19] No such device
>
>
> At this time, I cannot provide the full bitmap for copyright reasons,
> but I can provide some information about the bitmap:
>
> cameron at cameron-laptop:~$ file test.bmp
> test.bmp: PC bitmap data, Windows 3.x format, 1000 x 1000 x 8
>
> The same code works for .ppm images in the same folder:
>
> cameron at cameron-laptop:~$ convert test.bmp test.ppm
> cameron at cameron-laptop:~$ python
> import Image
> img=Image.open("test.ppm")
> data=img.getdata()
>
> But does not work for .pnm images in the same folder:
>
> cameron at cameron-laptop:~$ convert test.bmp test.pnm
> cameron at cameron-laptop:~$ python
> import Image
> img=Image.open("test.pnm")
> data=img.getdata()
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 796,
> in getdata
>     self.load()
>   File "/usr/local/lib/python2.5/site-packages/PIL/ImageFile.py", line
> 147, in load
>     self.map = mmap.mmap(file.fileno(), size)
> EnvironmentError: [Errno 19] No such device
>
>
>
>
> PIL Version on Linux and Windows:
>
> $Id: Image.py 2337 2005-03-25 07:50:30Z fredrik $
>
>
> How can I avoid this error without converting each image into a
> different format?  Is there any more information required?
>
>
> Thanks and regards,
>
> Cameron.
>

Hi all,

It turns out the error only arose when reading the file from an
ntfs-3g mounted drive in Linux.  If I copied the file to my home
directory it worked as expected.

Regards,

Cameron.


More information about the Image-SIG mailing list