467,104 Members | 963 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

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
  • viewed: 8518
Share:
2 Replies


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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by sandeep | last post: by
7 posts views Thread by The|Godfather | last post: by
18 posts views Thread by robert | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.