468,537 Members | 2,465 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

PIL throws exception when reading bitmap/pnm data

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@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@cameron-laptop:~$ convert test.bmp test.ppm
cameron@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@cameron-laptop:~$ convert test.bmp test.pnm
cameron@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?
Thanks and regards,

Cameron.
Nov 29 '06 #1
2 2440
Cameron Walsh 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
<SNIP>
>

Thanks and regards,

Cameron.

Hi all,

It turns out the problem only arose when the file was on an NTFS drive
mounted as NTFS-3g. Copying it to my home directory fixed the problem.

Who do I send the bug report to, the ntfs-3g or the PIL guys?

Regards,

Cameron.
Dec 1 '06 #2
Dennis Lee Bieber schreef:
Send a complaint to M$ requesting them to open document the NTFS
format... I've been out of the loop for a while, but the last time I
checked, NTFS was something that should be treated as read-only from
LINUX -- the recommendation was to make a small FAT-32 partition for any
data that needed to be shared.
Going off-topic, but there's another way nowadays: if your Linux
partitions use ext2 or ext3, you can use read/write them from Windows
with the file system drivers from http://www.fs-driver.org/
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
Dec 1 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sébastien Ros | last post: by
5 posts views Thread by Marco Castro | last post: by
3 posts views Thread by Nemisis | last post: by
4 posts views Thread by indrawati.yahya | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.