472,959 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,959 software developers and data experts.

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 2623
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Koji Ishii | last post by:
I'm trying to read response from a web server using XmlTextReader. Here's a code snippet. WebResponse rs = this.WebRequest.GetResponse(); Stream stm = rs.GetResponseStream(); XmlTextReader...
3
by: Sébastien Ros | last post by:
During the process of an XML document, I have to make a SelectNodes() call on an XmlDocument. It returns an isntance of XPathNodeList. I can call it several times but at one point, the result can't...
2
by: Boris Fortes | last post by:
I need to unhook event receiver as result of native C++ event. It unhooks successfully, but __raise does not return and throws access violation. Visual Studio 2003 How to reproduce: Consol...
3
by: T. Davis | last post by:
In C#, I am able to successfully stream a TIFF image that comes from a BLOB field in a database, save it to file, then convert the pages within TIFF file into jpegs (using GDI+) and display on the...
5
by: Marco Castro | last post by:
Along time ago I created an access database where I used the ole field type to store images. If I look at the table data it has the work Picture in its field. The image in that field displays...
3
by: Nemisis | last post by:
Hi everyone, Can someone please tell me why my code hits an "out of memory exception" on the below code? All the code does is load some documents from a SQL database and loop through a data...
4
by: indrawati.yahya | last post by:
According to the FAQ, the best way to inform a class user of an error that occurs inside a constructor is to throw an exception. My question is, what happens when an object is instantiated using...
0
by: yogiam | last post by:
I have a server listening for connections. Client connects and both start streaming webcam images. This works fine as long as there is only one client connected(running as a Thread). When another...
2
by: ouzsharp | last post by:
The follwing class works well when used in a C# console application: namespace ScreenShotDemo { /// <summary> /// Provides functions to capture the entire screen, or a particular...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.