New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageTk.getimage() is broken (again) #6020
Comments
When you say "again", could you elaborate on this? Are you saying that it has been broken with some Pillow versions for you and not others? Bear with me if you know this and think it is obvious, but p_img = PhotoImage(file='dir/img_name')
image = ImageTk.getimage(p_img) could be simplified to image = Image.open('dir/img_name') You may have just used that specific code to demonstrate the general problem however. Also, if you look at https://pillow.readthedocs.io/en/stable/installation.html#python-support, you will see that Pillow 8.0.1 is not intended to support Python 3.10. I doubt it would solve your problem, but I would recommend upgrading to a newer version of Pillow. |
Greetings, Yes, I am aware that I can use the code provided, and yes, you are correct that I used the code to demonstrate the issue. Thank you for the update suggestion. I am now running Pillow 9.0.0, however the issue still persists. |
Hi. Another question just to provide context - what version of Tkinter are you using? >>> from PIL import _tkinter_finder
>>> _tkinter_finder.tk_version
'8.6' |
It is 8.6 |
Ok, I've realised what the problem is - I've created PR #6032 to resolve this. If you would like an immediate solution, I find that the following code works. from tkinter import *
from PIL import Image, ImageTk
root = Tk()
# Clumsy way to activate Pillow's tkinter hooks
ImageTk.PhotoImage("RGB").paste(Image.new("RGB", (1, 1)))
p_img = PhotoImage("hopper.jpg")
image = ImageTk.getimage(p_img) |
Thanks! I'll close this issue now. |
What did you do?
Tried to convert a PhotoImage to a Image using the ImageTk library function
What did you expect to happen?
Get an Image from the PhotoImage
What actually happened?
got a TclError:
dir..\lib\site-packages\PIL\ImageTk.py", line 279, in getimage
photo.tk.call("PyImagingPhotoGet", photo, block.id)
_tkinter.TclError: invalid command name "PyImagingPhotoGet"
What are your OS, Python and Pillow versions?
The text was updated successfully, but these errors were encountered: