Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImageTk Paste
#7
O Wall I thought that was going to fix it but it's good that you got rid of the * imports Big Grin

self.overlay_img = ImageTk.PhotoImage(file=file)
self.overlay_img is a Tkinter-compatible photo image

self.photo = ImageTk.PhotoImage(image=Image.fromarray(frame))
self.photo is also a Tkinter-compatible photo image

When calling paste I think the passed in image has to be an actual PIL image.
self.photo.paste(self.overlay_img, (0, 0))

as self.overlay_img is used in the update method You probably need to keep self.overlay_img as it is
    def update(self):
        ...
        ...
        if self.overlay_img:
            #self.canvas.tag_raise(self.overlay_img)
            self.canvas.create_image(0,0, image=self.overlay_img, anchor=NW)


Here is what I hope will fix it Pray

When you make self.overlay_img try also making a pill image
    def overlay(self):
        file = filedialog.askopenfile(
            mode='rb', defaultextension='.png',title="Choose Overlay Image", filetypes=[("PNG Files", '*.png')])
        if file:
            self.overlay_img = ImageTk.PhotoImage(file=file)
            self.pil_overlay_img = Image.open(file)
Then change
if isTrue and self.overlay_img:
    self.photo.paste(self.overlay_img, (0, 0))
to
if isTrue and self.pil_overlay_img:
    self.photo.paste(self.pil_overlay_img, (0, 0))
Reply


Messages In This Thread
ImageTk Paste - by KDog - May-31-2021, 09:47 PM
RE: ImageTk Paste - by bowlofred - May-31-2021, 10:29 PM
RE: ImageTk Paste - by Yoriz - May-31-2021, 10:31 PM
RE: ImageTk Paste - by KDog - Jun-01-2021, 03:07 PM
RE: ImageTk Paste - by Yoriz - Jun-01-2021, 04:40 PM
RE: ImageTk Paste - by KDog - Jun-01-2021, 09:19 PM
RE: ImageTk Paste - by Yoriz - Jun-01-2021, 10:16 PM
RE: ImageTk Paste - by deanhystad - Jun-01-2021, 10:20 PM
RE: ImageTk Paste - by KDog - Jun-02-2021, 11:28 AM
RE: ImageTk Paste - by Yoriz - Jun-02-2021, 11:39 AM
RE: ImageTk Paste - by KDog - Jun-02-2021, 12:54 PM
RE: ImageTk Paste - by deanhystad - Jun-02-2021, 05:06 PM
RE: ImageTk Paste - by KDog - Jun-02-2021, 09:42 PM
RE: ImageTk Paste - by deanhystad - Jun-03-2021, 03:27 AM
RE: ImageTk Paste - by KDog - Jun-27-2021, 11:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What script to paste folders thenewcoder 1 678 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  PIL ImageTk issue with MATPLOTLIB garynewport 0 1,799 Jan-17-2023, 11:32 AM
Last Post: garynewport
  Please help me [copy and paste file from src to dst] midomarc 2 1,027 Nov-24-2022, 10:13 PM
Last Post: midomarc
  Cut and Paste Oshadha 3 2,449 Jan-20-2021, 04:27 PM
Last Post: spaceraiders
  copy paste file and re-name it asheru93 1 2,386 May-24-2019, 10:43 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020