[PYTHON IMAGE-SIG] PIL Feature Summary

Fredrik Lundh fredrik_lundh@ivab.se
Thu, 30 May 1996 01:37:07 +0200

> How about hooking it up so images can be displayed using a Tkinter
> Photo widget?  With a little effort someone could then come up with
> an xv like tool that just uses Python, Tkinter and PIL.

Well, have a look at the pilview.py hack in the 0.1b1 release.

It uses the ImageTk module which contains a PhotoImage class.  You
provide a mode and a size, and get an object into which you can paste
stuff.  When it's time to display it, accessing the image attribute
will create a Tk PhotoImage that can be passed to Tkinter.

The 0.1b2 release contains similar stuff for Windows (and an even more
rudimentary viewer hack).

The show() method is mainly intended for debugging, and quick hacks.

> Anyway, I was just piping up since you were feeling lonely.

Surely appreciated.  There's a lot of people lurking around here, but
you don't see much of them, do you?


# here's a minimal viewer supporting ~15 formats (with 0.1b2)

import Image, ImageTk, Tkinter

def show(i):

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

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

if __name__ == "__main__":
    import sys
    if len(sys.argv) > 1:
	file = sys.argv[1]
	file = "lena.ppm"

IMAGE-SIG - SIG on Image Processing with Python

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