[PYTHON IMAGE-SIG] Making an Image fromstring()

Dale C. Bertrand dcb@lems.brown.edu
Wed, 3 Jul 1996 16:39:38 -0400

I'm trying to make a PIL Image from a string of data.  I've used the
show() method on the Image which successfully brings up and xv
window displaying my string as an image.  The problem is:  when I
convert that image to a PhotoImage and try to use it on a label (an
operation that has worked for me in the past) it gives me an "image
doesn't exist error."  Does anyone know how I can get this to work?

The code and error message are listed below.

Dale Bertrand

--- CODE ---

i = new("L",(128,128))  # The demensions are (128,128) 
			# and the image is greyscale

string_data = _ImageMagick.MIFFToString(image) # The string is the right
					       # length (128*128)
i._fromstring( string_data )

i.show()  # This pops up an xv representation of my image beautifully

tkim = ImageTk.PhotoImage(i.mode,i.size)

root = Tk()
label = Label(root,image=tkim)


  File "ImageMagick.py", line 61, in ?
    label = Label(root,image=tkim)
  File "/vision/packages/Python/1.3/lib/python/tkinter/Tkinter.py", line 1093, in __init__
    Widget.__init__(self, master, 'label', cnf, kw)
  File "/vision/packages/Python/1.3/lib/python/tkinter/Tkinter.py", line 786, in __init__
    Widget.config(self, cnf)
  File "/vision/packages/Python/1.3/lib/python/tkinter/Tkinter.py", line 807, in config
    apply(self.tk.call, (self._w, 'configure')
TclError: image "<PhotoImage instance at b5e38>" doesn't exist

IMAGE-SIG - SIG on Image Processing with Python

send messages to: image-sig@python.org
administrivia to: image-sig-request@python.org