Mar-24-2024, 06:25 PM
Not an answer, but a problem:
I was interested, so I set:
img = '/home/pedro/Pictures/aphrodite.jpg'
Trying out the code, I am getting:
Maybe 1 image could be corrupt, so I tried 2 other images, no joy!
This works:
I was interested, so I set:
img = '/home/pedro/Pictures/aphrodite.jpg'
Trying out the code, I am getting:
Quote:Main().mainloop()
Traceback (most recent call last):
File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "<pyshell#20>", line 1, in <module>
File "<pyshell#8>", line 6, in __init__
File "<pyshell#17>", line 6, in __init__
File "/usr/lib/python3.10/tkinter/__init__.py", line 4103, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python3.10/tkinter/__init__.py", line 4048, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "/home/pedro/Pictures/aphrodite.jpg"
Maybe 1 image could be corrupt, so I tried 2 other images, no joy!
This works:
from PIL import Image im = Image.open(img) im.show()Any ideas what may be the problem?
Quote:bg = tk.PhotoImage(file=img)
Traceback (most recent call last):
File "/usr/lib/python3.10/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "<pyshell#28>", line 1, in <module>
File "/usr/lib/python3.10/tkinter/__init__.py", line 4103, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python3.10/tkinter/__init__.py", line 4048, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize data in image file "/home/pedro/Downloads/aphrodite.jpg"