473,219 Members | 2,137 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,219 software developers and data experts.

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 6058
| ....
| 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
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
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
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
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
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
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
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
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
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...
1
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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.