f



tkinter, loading image error, TclError: couldn't recognize data in image file "C:/users/me/desktop/images/blob4.jpg"

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
-1
circularfunc (118)
6/29/2008 11:34:37 AM
comp.lang.python 77058 articles. 6 followers. Post Follow

2 Replies
3886 Views

Similar Articles

[PageSpeed] 38


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

1
tjreedy (5460)
6/29/2008 6:54:25 PM
On Sun, 29 Jun 2008 13:34:37 +0200, defn noob <circularfunc@yahoo.se>  =

wrote:

> from Tkinter import *
> import os
>
> master =3D Tk()
> w =3D Canvas(master, width=3D800, height=3D600)
>
> print os.path.exists('C:/me/saftarn/desktop/images/blob4.jpg')
>
> im =3D PhotoImage(file =3D '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 =3D PhotoImage(file =3D '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+-'])"
1
6/30/2008 9:26:27 AM
Reply:

Similar Artilces:

"Toolbar error: Couldn't add an image to the image list"
Dear fellow wxWidget developers! I just wanted to learn more about wxToolbar and it's capabilities, so I compiled the example at $(WXDIR)/samples/toolbar and got the error above when trying to [X] Use custom disabled images. void MyFrame::RecreateToolbar() didn't seem to be the culprit, no popup thrown in there... How can I trace what's going on? Environment: Win2K, Microsoft Visual C++ .NET V 7.1, wxMSW-2.6.2 Thanks a lot! Volker P.S.: While we are at it: Is transparency/alpha channels supposed to work with wxBitmap()s wxToolbar::AddTool()-ed via external...

"Couldn't recognize image data"
Hi. I'm trying to use the Img extension to capture data from a canvas to an image. Someone on the wiki put together a little "WindowToFile" demo here: http://wiki.tcl.tk/9127 I modified that slightly by adding: canvas $top.c pack $top.c -side top -expand 1 -fill both before the "update", and then: $top.c create line 100 100 200 200 -fill black after the "update" in the demo proc. This adds a canvas with diagonal line. When I run this, it works! However, when I try this on a canvas within a more complicated application (probably 10 to 12 level...

"image put", "image data" and the TclMagick commands "$wand readblob", "$wand writeblob"
Hello, recently I was suprised of some facts, that made code I wrote easier and more complicate, too! I used TclMagick to process some JPEG files and thought about connecting this with Tk. So reading and processing a JPEG file and using it inside a label is really unproblematic: package require Tk; package require Img; package require TclMagick; set image [image create photo]; set wand [magick create wand]; $wand read $jpegfile; $wand enhance; $wand resample 96 96 mitchell; $wand enhance; $image put [$wand writeblob]; label .l -image $im...

How to change the pic to a "show error" image when loading images failed?
How to change the pic to a "show error" image when loading images failed - for example, no image file exists? I tried to add the following statement in the onload event function: if (!document.images.AImage.complete) { document.images.AImage.src = "error.gif";); } However, I found that a lot of images can be successfully loaded will also be replaced with the "error.gif". After remove above line, these exist images can be show successfully. But I want to change the non-exist images src to the error.gif.... Nick wrote: > How to change the pic to a "...

Size of "image"-images' pixels
Hello, which size will a pixel have, that is used with the image-operator? Didn't found a specification for it. TIA, Oliver P.S.: Why are those pixels not sharp displayed? When I use the examples from the Bluebook, I got smeared grafics, so there are not sharp edges. Looks like aliasing or something like that..?! In article <1115414000.431902@elch.in-berlin.de>, Oliver Bandel <oliver@first.in-berlin.de> wrote: >which size will a pixel have, that is used >with the image-operator? > >Didn't found a specification for it. Look in the...

Saving image on clipboard to file, or a contextual menu with "Save image to file"?
I've found myself having to save an image from the clipboard to a file a few times lately and have done the following: 1) Open GraphicConverter 2) Create a new canvas of large size 3) Pasting the image 4) Cropping the canvas down to the image size 5) Saving I'd really like to do this in fewer steps. Is there an application or something that will let me save directly from the clipboard to a file? (I don't care what image format it saves as.) What about a contextual menu? What about a different application that will let me streamline the above process? Thanks! -Lotofun In ar...

"Real WMV", 148.50 mhz sample-rate, 1920 X 1080 progressive scan image, "object data" bit-rate of 1bps -- Why Can't It Exist??
Bob Myers wrote in http://groups.google.com/group/sci.electronics.basics/msg/0d0bbebafddcd749?hl=en& : > "Radium" <glucegen1@excite.com> wrote in message > news:1162073248.034840.25900@h48g2000cwc.googlegroups.com... > Once you do that, you will no longer be asking > questions like: > > > So it is true that 1-bit movie cannot exist. What about a WMV file that > > is 148.50 Mhz sample-rate, 1920 x 1080 progressive scan image, whose > > object data rate is a CBR of 1 bit per second? Could this exist? In 2 > > hours or this video, the fil...

How to check jpg image: Warning: JPEG library error (8 bit), "Premature end of JPEG file"."
Hi, I have a problem with loading jpg images. I'm running a C++ model and a Matlab program side by side (on Ubuntu). Basically, the C++ model outputs jpg's and the Matlab program tries to read them as soon as they are available. Speed is important: I want to load them as soon as they are output by C++/ My looks something like this: while 1 listJPG = dir('folder/*.jpg'); if length(listJPG) ~= 0 && listJPG.bytes > 10 try images = imread(listJPG(1).name) break end end pause(.001) end Most of the times it works fine, however, sometimes I get the following warning: Warning: JPEG library error (8 bit), "Premature end of JPEG file"." My questions: 1. What does this error mean, is it not reading the entire image because it is not completely saved yet? 2. How do I prevent this from happening, without using a longer pause, as the code needs to be as fast as possible. Thanks! ...

Is mime type "image\dicom+jpeg" the same as "image\jpeg" ?
PS3.18, 7.1, Single Frame Image Objects, mentions mime type image\dicom+jpeg but never defines it. (http://tools.ietf.org/html/rfc2045 ?) It this equivalent to image\jpeg in that the body part consists of only the pixels rendered as jpeg (with optional transfer syntax specified) image/dicom+jpeg; transfer-syntax=1.2.840.10008.1.2.4.50 or is image\dicom+jpeg meant to contain the entire dicom object with pixels in JPEG? Equivalent to multipart/related=application/dicom+jpeg I favor the image\jpeg interpretation but I have a co-worker concerned about the "dicom" in image/d...

wx.Image: Couldn't add an image to the image list.
I would like to load image from a directory right into an image list. I wrote a simple library that loads the images in the directory and resizes them as needed before adding to the wx.ImageList. This is not the same code but some snippets. I resize the image this way (using Python Imaging Library): def resizeimage(image,newsize): oldsize = (image.GetWidth(),image.GetHeight()) if oldsize != newsize: return piltoimage(resizepil(imagetopil(image),newsize)) else: return image This is how I convert images to a bitmaps: bmp = wx.BitmapFromImage(image,depth=depth) I have ...

error: "couldn't execute "date": no such file or directory" in Tk
hi, i am using the following code in a tcl script with the TK framework, and i get the above error on executing the file main file.. main file --------------- #!c:/tcl/bin/tclsh label .l -text "click to execute" button .b -text "Execute" -command "exec_script" proc exec_script {} { set inp 1 source sss.tcl puts $inp } pack .l .b sss.tcl ----------------------------- #!c:/tcl/bin/tclsh set inp 0 puts $inp set d [exec date] The error i get is "couldn't execute "date": no such file or directory" I am using Tk with Tcl and it is necessary to print the date along with along with my output. The "exec date" works perfect in a tcl script only. but when i use it along with TK i get the error... i will be glad if someone could please help me... thank you.. On 21 Feb., 12:42, "ronnie" <maninder....@gmail.com> wrote: > set d [exec date] > > The error i get is "couldn't execute "date": no such file or > directory" Since Tcl 7.6 or so, the [clock] function delivers date and time in a portable way. See http://www.tcl.tk/man/tcl8.4/TclCmd/clock.htm Examples: 53615 % clock format [clock seconds] Wed Feb 21 12:48:09 W. Europe Standard Time 2007 84 % clock format [clock seconds] -format %c Mittwoch, 21. Februar 2007 12:48:21 53 % clock format [clock seconds] -format %Y-%m-%d,%H:%M:%S 2007-02-21,12:49:42 That [exec date] does work at times, and not at ...

PIL Image can't open png file with "I"?
Hi, I have png file with mode "I", 16 bit, And I tried to open it with im=3DImage.open("output.png"), im.show() I got all white image. Don't why? Can Image only support 'RGB' or 'RGBA' png files? Thanks=20 James Hi ! Perhaps... ";" better than "," : im=Image.open(r"C:\vodka3.png"); im.show() Perhaps... more simplist : im=Image.open(r"C:\vodka3.png").show() Perhaps... other thing ? @-salutations Michel Claveau ...

Drive Image 2002
When I make a D.I. file I usually add some appropriate remarks. These are added when the D.I. "DOS" is displayed just before the Image is created . I have several Image files of my XP drive one of which was created just before I installed SP2 and I made a remark to that effect at the time. Is there any way to access these remarks in Windows without going back into the D.I. "DOS" files ? B.N. -- to reply by e-mail remove "admiral_" admiral_victory@iol.ie wrote: > When I make a D.I. file I usually add some appropriate remarks. > > T...

Can't locate object method "newFromJpeg" via package "GD::Image"
Hi. I'm trying to execute this Perl simple script: -------- #!/usr/bin/perl use GD; my $srcimage = GD::Image->newFromJpeg("image_news.jpg"); my ($srcW,$srcH) = $srcimage->getBounds(); --------- But I get this error message: ------- Can't locate object method "newFromJpeg" via package "GD::Image" at ../test.pl line 3. ------- I've got GD and libgd compiled with JPEG support turned on. 1) JPEG libs + Downloaded from http://www.ijg.org/files/jpegsrc.v6b.tar.gz + mkdir /usr/local/jpeg-6b + mkdir /usr/local/jpeg-6b/bin + mkdir /usr/local/...

headers for "image not found" image
I'd like to serve an image-not-found image for images... that aren't found.. I'm already using a custom 404 handler page.. but this question could apply to images retrieved from a database or script or whatever... Anyhow, is the 1st method OK, or should #2 be used? ie, does the client/bot or whatever recognize the 404 on method 1? Or, does it think everything is dandy because of the redirect. header('HTTP/1.0 404 Not Found'); header('location: '.$image_url); exit; or header('HTTP/1.0 404 Not Found'); header('Content-Type: image/whatever'); readf...

Are "disk images" disk images or not?
I have seen the question "What are disk images" answered numerous times with the assurance that they are exact sector-by-sector copies of real physical disks. But my own eyes seem to contradict that apparently standard answer. Disregarding the instant .dmg "images" which can be cobbled together in folders on the desktop, and concentrating on sincere attempts to create real images of real physical disks with Disk Utility, if .dmg's are real sector-by-sector copies, how come they shrink in size when files are deleted from their source-devices to make the "images&quo...

tkinter photoimage, couldn't recognize image data (PPM)
Hi all, I've tried to display an image with the source being a string but it fails (see below). Is there a way to display PPM without writing it first to a file? Thanks, Martin ----- snippet ----- ''' Ubuntu 9.04 64bit, python 3.1 ''' import tkinter DATA="""P3 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0""" def display(): tk = tkinter.Tk() canvas = tkinter.Canvas(tk, width=3, height=2) canvas._image_reference = tkinter.PhotoImage(format='ppm&#...

img::ps: couldn't recognize data in image file
Hello, I've got an error "couldn't recognize data in image file "c:/test.PS" while executing "image create photo -file $fileName" ... from proc CreatePostscriptImage { fileName } { package require img::ps return [image create photo -file $fileName] } pack [label .l -image [CreatePostscriptImage c:/test.PS]] Ghostscript is installed (often used, interacts well with ImageMagic). Win2000, WinXP. Where is the problem? Thank you. Alexei K. wrote: > Hello, > > I've got an error > "couldn't recognize data in image file "c...

"Philips MR Imaging DD 001" vs "Philips Imaging DD 001"
I was reading the changelog of dicom3tools : .... 090106: libsrc/standard/elmdict/philips.tpl,appsrc/dcfile/ Imakefile,antodc.cc: label (2005,xx33,"Philips MR Imaging DD 001") as Acquisition Duration, based on observation that value is the same as (0018,9073) in enhanced MR IODs, .... Which made me realize that a couple of tags in between "Philips MR Imaging DD 001" and "Philips Imaging DD 001" are suspiciously *very* similar. for instance (2005,xx30,"Philips MR Imaging DD 001") really looks like it contains the repetition time,...

Problem reading "png", 'jpg" images with Tk::Photo
Hi, I have been trying to read ".png" & ".jpg" image files using "Tk::Photo". The code works fine if I use ".xpm" or ".gif". =================== perl -v This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 18 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Binary build 822 [280952] provided by ActiveState http://www.ActiveState.com Built Jul 31 2007 19:34:48 ============================== Here is my code use Tk; use warnings; use strict; my $mw = new MainWindo...

what's the difference of "image" and "imshow"
Hello, All! as showed in title. when i execute the following script: i=imread('moon.tif'); image(i); %it don't show picture correctly however,if i use "imshow(i)",then it works Thanks for repling antique. E-mail: ck21007@sohu.com antique wrote: > Hello, All! > > as showed in title. > when i execute the following script: > i=imread('moon.tif'); > image(i); %it don't show picture correctly > > however,if i use "imshow(i)",then it works Check you current colormap: image(i) colormap(gray(256)); should give identica...

how to connect &quot;IMAQ Get Buffer.vi&quot; output terminal of &quot;Image Out&quot; to the input terminal of &quot;Image&quot; of &quot;IMAQ ColorImageToArray.vi&quot;
Hi, Thanks a lot for helping me till this stage.I am again stuck up with some problem.Please help me this time also. Actually i am making changes in already existingblock diagram and also i am new to this labview programming.And also time is very crucial. So i want to know if there is any way to connect the output of Image out terminal of IMAQ Get Buffer.vi to the input terminal of Image of IMAQ ColorImageToArray.vi. In the actual block diagram the output of Image out terminal of IMAQ GetBuffer.vi is connected to the input terminal of Image of IMAQ ImageToArray.vi. I want to change this becos ...

Why doesn't Python's "robotparser" like Wikipedia's "robots.txt" file?
For some reason, Python's parser for "robots.txt" files doesn't like Wikipedia's "robots.txt" file: >>> import robotparser >>> url = 'http://wikipedia.org/robots.txt' >>> chk = robotparser.RobotFileParser() >>> chk.set_url(url) >>> chk.read() >>> testurl = 'http://wikipedia.org' >>> chk.can_fetch('Mozilla', testurl) False >>> The Wikipedia robots.txt file passes robots.txt validation, and it doesn't disallow unknown browsers. But the Python pars...

TI & CCS
I've just recently moved from SHARC & Visual DSP to TIC6713 with Code Composer Studio. I am working through the tutorials and I have met a problem: In the second tutorial "Project Management" I follow the instructions but when I try to build the project I get: ===================================================== ------------------------- maxminlibrary.pjt - Debug ------------------------- Error, Don't know how to build file "C:\ti\tutorial\dsk6713\maxminmath \maxminlibrary.cmd" [maximumvalue.c] "c:\ti\c6000\cgtools\bin\cl6x" -g -q - fr"C...

Web resources about - tkinter, loading image error, TclError: couldn't recognize data in image file "C:/users/me/desktop/images/blob4.jpg" - comp.lang.python

Resources last updated: 2/22/2016 9:04:31 AM