[Tkinter-discuss] Using PIL with Tkimg

Michael Lange klappnase at web.de
Sun Jan 7 18:33:44 CET 2007


On Sun, 07 Jan 2007 13:42:11 +0100
Fredrik Lundh <fredrik at pythonware.com> wrote:

> Michael Lange wrote:
> 
> > 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?)
> 
> nope.
> 
> > which sometimes results in a significant loss of quality.
> 
> are you perhaps using nearest-neighbour filtering?  try using BILINEAR 
> (or, if you have the CPU, ANTIALIAS) instead.
> 
> </F>

Thanks Frederik,

as usually you are right, using ANTIALIAS it is much better.
Still some images are not displayed correctly; I have uploaded a little demo
screenshot of what I mean to <http://klappnase.zexxo.net/Tkimg_vs_PIL.html>.

The PIL image in this example looks a lot like a GIF image created with convert
or some other utility from the original PNG, that is why I thought about the
on-the-fly conversion into GIF.
When I call Image.save() on the image returned by Image.open() the resulting image looks
ok, so I guess the problem must be with the ImageTk.PhotoImage .
Is there any way to avoid effects like these that I missed so far?

Thanks in advance

Michael


More information about the Tkinter-discuss mailing list