473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 2647
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...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.