473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PIL always raises "unrecognized image mode" exception with putdata()

How does Image.putdata() work? I am using PIL 1.1.3.
This simple script throws an exception on putdata():

import Image
width = 10
height = 10
im = Image.new ("RGB", (width, height))
L = list(im.getdata())
k = 0
for y in range (height):
for x in range (width):
L[k] =(127,127,127)
k += 1
im.putdata(L, 1.0, 0.0)
im.save ('target_out.png', 'png')

I get this output:

Traceback (most recent call last):
File "test.py", line 13, in ?
im.putdata(L, 1.0, 0.0)
File "/usr/local/lib/python2.2/site-packages/PIL/Image.py", line 661,
in putdata
self.im.putdata(data, scale, offset)
TypeError: unrecognized image mode

In fact even the following trivial script fails:

import Image
width = 10
height = 10
im = Image.new ("RGB", (width, height))
im.putdata (im.getdata())

It seems simple enough. What's the trick? Is my PIL too old?

Yours,
Noah
Jul 18 '05 #1
3 6160
| ....
| im.save ('target_out.png', 'png')
| ....

Noah ....

Try the image type in all-caps ....

im.save( 'targe_out.png' , 'PNG' )

Also, you might try the Image save method
with just the filename and omit the type argument ....

im.save( 'target_out.png' )

Unless you specify the format, the library
uses the filename extension to discover
which file storage format to use.

--
Cousin Stanley
Human Being
Phoenix, Arizona

Jul 18 '05 #2
"Cousin Stanley" <Co***********@hotmail.com> wrote in message news:<c0*************@ID-130333.news.uni-berlin.de>...
| ....
| im.save ('target out.png', 'png')
| ....
Noah ....
Try the image type in all-caps ....
im.save( 'targe out.png' , 'PNG' )
Also, you might try the Image save method
with just the filename and omit the type argument ....
im.save( 'target out.png' )
Unless you specify the format, the library
uses the filename extension to discover
which file storage format to use.


But my problem is with getdata() and putdata().
The PIL raises the exception even when saving or loading is not involved.
For example, the following script raises the exception
"TypeError: unrecognized image mode.

import Image
width = 10
height = 10
im = Image.new ("RGB", (width, height))
im.putdata (im.getdata())

Yours,
Noah
Jul 18 '05 #3
On 9 Feb 2004 12:23:33 -0800, no**@noah.org (Noah) wrote:

This worked just fine for me...
Win2000, Python 2.3.2,PIL 1.1.4
How does Image.putdata() work? I am using PIL 1.1.3.
This simple script throws an exception on putdata():

import Image
width = 10
height = 10
im = Image.new ("RGB", (width, height))
L = list(im.getdata())
k = 0
for y in range (height):
for x in range (width):
L[k] =(127,127,127)
k += 1
im.putdata(L, 1.0, 0.0)
im.save ('target_out.png', 'png')

I get this output:

Traceback (most recent call last):
File "test.py", line 13, in ?
im.putdata(L, 1.0, 0.0)
File "/usr/local/lib/python2.2/site-packages/PIL/Image.py", line 661,
in putdata
self.im.putdata(data, scale, offset)
TypeError: unrecognized image mode

In fact even the following trivial script fails:

import Image
width = 10
height = 10
im = Image.new ("RGB", (width, height))
im.putdata (im.getdata())

It seems simple enough. What's the trick? Is my PIL too old?

Yours,
Noah


Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3033
by: Roger Shrubber | last post by:
I have a page with images that the user can drag from one frame to another. I need them to see a "ghost image" of the image they are dragging, while the original stays put. I use the onmousemove...
7
26755
by: qbsu21th | last post by:
Dear Sir/Madam, I'm writing a small VB6.0 and Access 2002 application in XP OS. I selected the data control property RecordSource, I got the "Unrecognized database format 'xxx/xx/*.mdb' " error....
2
15445
by: hazz | last post by:
I have spent more time than I care to admit trying to track down a very subtle error. Here is my app's xx.exe.config file. <?xml version="1.0" encoding="utf-8" ?> <configuration>...
21
4938
by: nicholas | last post by:
Although in my web.config I have <customErrors mode="off" /> I still get no detailed errors. How comes ? THX This is what I get: Server Error in '/mywebfolder'Application.
2
1306
by: Nalaka | last post by:
Hi (I am using visual studio 2005 beta 2) I have a simple asp.net data grid, with a edit (update and cancel) set. When the button mode is link, it works fine. But when the button mode is...
1
6178
by: Trygve Lorentzen | last post by:
Hi, my webservice is running on Win2000 SP4, IIS 5.0 fully patched, connecting to a MySQL database and mainly returning Typed DataSet's from webmethods. After running for a while, generally a...
2
2734
by: Alan Silver | last post by:
Hello, If I have the following HTML... <input type="image" src="fred.gif"> .... is there a way to specify the image in CSS rather than in the HTML? TIA
6
6278
by: sloan | last post by:
I have a fairly simple RegEx code below. I am given a file name, (which I don't control) , and need to change a folder name in it. The code below is choking on the filename not being...
1
3167
by: =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post by:
Hi I am creating a web service PreprocessingService with IIS Hosting and transport layer security with user name and password. I created a self-signed certificate IISHost in IIS which is issued...
0
7198
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
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7319
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...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.