[Tkinter-discuss] Using PIL with Tkimg

Michael Lange klappnase at web.de
Sat Jan 6 20:11:56 CET 2007

First, a happy new year to all of you!

And now for something completely different:

I want to display different image formats in a Tkinter.Canvas and be
able to scale the images to a requested size. I noticed that some images
look better when using Tkimg than with PIL, which just seems to
do an on-the-fly conversion into GIF (is this correct?) which sometimes
results in a significant loss of quality.
Unfortunately when using Tkimg with a plain Tkinter.PhotoImage
there is not much support for scaling the image, so I tried to use them both,
however without luck. The ImageTk.PhotoImage seems to ignore the native
file format support provided by Tkimg and I could not find a way to send
the image data from the resized PIL Image to a standard Tkinter.PhotoImage .

I tried passing the data returned by Image.tostring() to the PhotoImage's
data argument, but without success.

Does anyone know, is this possible at all, and if it is, how to accomplish this?

Thanks in advance


More information about the Tkinter-discuss mailing list