Re: [Image-SIG] PhotoImage Class
by Fredrik Lundh other posts by this author
Apr 6 2006 6:19AM messages near this date
[Image-SIG] PhotoImage Class
|
[Image-SIG] Error when saving JPEG with quality above 85 and optimize
Eric Germaneau wrote:
> I wish to ise the photimage class and I'm wondering wether someone would
> have an example ....
the basics are really simple:
import ImageTk
photo = ImageTk.PhotoImage(file="somefilename")
or
im = ... some image operation ...
photo = ImageTk.PhotoImage(im)
The resulting object can be used everywhere you can use a Tkinter.PhotoImage
object
http://effbot.org/tkinterbook/photoimage.htm
e.g.
label = Label(image=photo)
here's a complete example:
import sys
import Image, ImageTk, Tkinter
root = Tkinter.Tk()
im = Image.open(sys.argv[1])
im.thumbnail((400, 400))
photo = ImageTk.PhotoImage(im)
label = Tkinter.Label(root, image=photo)
label.pack()
# see note on http://effbot.org/tkinterbook/photoimage.htm
label.image = photo
root.mainloop()
the above script loads the image given as an argument, resizes it to 400x400 (max),
and displays it in a Tkinter label widget.
hope this helps!
</F>
_______________________________________________
Image-SIG maillist - Image-SIG@[...].org
http://mail.python.org/mailman/listinfo/image-sig
Thread:
Eric Germaneau
Fredrik Lundh
|