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

tkinter, loading image error, TclError: couldn't recognize data in

from Tkinter import *
import os

master = Tk()
w = Canvas(master, width=800, height=600)

print os.path.exists('C:/me/saftarn/desktop/images/blob4.jpg')

im = PhotoImage(file = 'C:/users/saftarn/desktop/images/blob4.jpg')
#im = file = 'C:/users/me/desktop/images/blob4.jpg'
pic = w.create_image(0, 0, image = im, anchor = NW)

#image = open('C:/users/saftarn/desktop/images/blob.png')

colors = []
for x in range(1, 800):
for y in range(1, 600):
pic = w.find_closest(x, y)[0]
obj = objects[pic]
colors.append(obj.get(int(x), int(y)))

print colors
>>>
True

Traceback (most recent call last):
File "C:/Python25/Progs/ImageVideoSearch/imId.py", line 9, in
<module>
im = PhotoImage(file = 'C:/users/me/desktop/images/blob4.jpg')
File "C:\Python25\lib\lib-tk\Tkinter.py", line 3270, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 3226, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: couldn't recognize data in image file "C:/users/me/desktop/
images/blob4.jpg"
>>>


it has worked before opening and displaying a file like this, anything
to do with python 2.52, upgraded from 2.5.1
Jun 29 '08 #1
2 10073


defn noob wrote:
from Tkinter import *
import os

master = Tk()
w = Canvas(master, width=800, height=600)

print os.path.exists('C:/me/saftarn/desktop/images/blob4.jpg')

im = PhotoImage(file = 'C:/users/saftarn/desktop/images/blob4.jpg')
#im = file = 'C:/users/me/desktop/images/blob4.jpg'
pic = w.create_image(0, 0, image = im, anchor = NW)

#image = open('C:/users/saftarn/desktop/images/blob.png')

colors = []
for x in range(1, 800):
for y in range(1, 600):
pic = w.find_closest(x, y)[0]
obj = objects[pic]
colors.append(obj.get(int(x), int(y)))

print colors

True

Traceback (most recent call last):
File "C:/Python25/Progs/ImageVideoSearch/imId.py", line 9, in
<module>
im = PhotoImage(file = 'C:/users/me/desktop/images/blob4.jpg')
File "C:\Python25\lib\lib-tk\Tkinter.py", line 3270, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 3226, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: couldn't recognize data in image file "C:/users/me/desktop/
images/blob4.jpg"

it has worked before opening and displaying a file like this, anything
to do with python 2.52, upgraded from 2.5.1
Did it work with that exact file? Have you tried other files that did
work with 2.5.1? The error comes from tcl/tk, not Python. I expect
that the version of tcl/tk delivered with 2.5.2 is exactly the same as
that delivered with 2.5.1, just to avoid such problems.

Note that even if one program displays a file it may still be slightly
corrupt and properly fail to display with another. If you have an image
editor, you might try opening and saving (different name) without changing.

tjr

Jun 29 '08 #2
On Sun, 29 Jun 2008 13:34:37 +0200, defn noob <ci**********@yahoo.se
wrote:
from Tkinter import *
import os

master = Tk()
w = Canvas(master, width=800, height=600)

print os.path.exists('C:/me/saftarn/desktop/images/blob4.jpg')

im = PhotoImage(file = 'C:/users/saftarn/desktop/images/blob4.jpg')
[snip]
>>>>
True

Traceback (most recent call last):
File "C:/Python25/Progs/ImageVideoSearch/imId.py", line 9, in
<module>
im = PhotoImage(file = 'C:/users/me/desktop/images/blob4.jpg')
File "C:\Python25\lib\lib-tk\Tkinter.py", line 3270, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 3226, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
TclError: couldn't recognize data in image file "C:/users/me/desktop/
images/blob4.jpg"
>>>>

it has worked before opening and displaying a file like this, anything
to do with python 2.52, upgraded from 2.5.1
Did it? Because AFAIK, tcl/tk has never natively recognized any other
image format than PPM/PGM and GIF... No JPG, no PNG...
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
Jun 30 '08 #3

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

Similar topics

1
by: midtoad | last post by:
I'm trying to display a GIF image in a label as the central area to a Tkinter GUI. The image does not appear, though a space is made for it. Why is this so? I notice that I can display a GIF...
1
by: dbuchanan | last post by:
VB.NET 2003 / SQLS2K The Stored Procedure returns records within Query Analyzer. But when the Stored Procedure is called by ADO.NET ~ it produced the following error message. ...
0
by: sandeep | last post by:
Mine requirement is to Put images on report(version which come with VS.NET) dynamically. For example if manager is looking a report then Image1.bmp should come and if normal Employee is looking for...
2
by: Henrik | last post by:
im reciving an error when i tries to read multidimensional XML data, into my system. I'm receving the same errors discriped at: http://support.microsoft.com/default.aspx?scid=kb;en-us;325695...
7
by: The|Godfather | last post by:
Hi everybody, I read Scotte Meyer's "Effective C++" book twice and I know that he mentioned something specific about constructors and destructors that was related to the following...
18
by: robert | last post by:
Is there a ready made function in numpy/scipy to compute the correlation y=mx+o of an X and Y fast: m, m-err, o, o-err, r-coef,r-coef-err ? Or a formula to to compute the 3 error ranges? ...
2
by: khalidanwar123 | last post by:
i am getting the following error while updating a clob field. ERROR java.sql.SQLException: Data size bigger than max size forthis type: 4003 19:28:27,499 ERROR at...
6
by: aaronkmar | last post by:
Trying to get a loading image to spin while the query is loading. I can get the data div to fade in, but I can't seem to figure out how to get the gif while the query is loading. I'm using two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.