PhotoImage.paste

Peter Otten __peter__ at web.de
Tue Jan 24 11:59:05 EST 2017


rryan.asu at gmail.com wrote:

> I'm trying to build a tkinter GUI with python 3.5, and would like to
> interactively adjust the color palette for an image by moving the mouse in
> the canvas using PIL.  In pseudo-code, I have something like
> 
> palette=color_map(x,y)   # x,y are scalars indicating the position of the
> mouse in the Canvas image.putpalette(palette)
> photo.paste(image)
> 
> This works just fine, but is very slow.  The photo.paste(image) step takes
> about 0.15 s (using an image that is 4k x 4k).  I read the manual on
> effbot, and they caution that the paste method would be slow if the image
> is display --- and I'm guessing that's what I'm doing.

So you have read

"""
Note: Pasting into an RGBA image that is displayed is a very slow operation. 
It’s usually better to create a new image object.
"""

on <http://effbot.org/imagingbook/imagetk.htm>.

> So my question is, what alternatives do I have to speed that step up.

Did you try to create a new image, as the note suggests?

> Thank you for any thoughts you might have...
> -Russell





More information about the Python-list mailing list