import base64
from tkinter import *
from PIL import ImageTk,Image
imgstring="/9j/4AAQSkZJRgABAQEASABIAAD/4QCMRXhpZgAASUAADADEBFAH/2Q=="
imgdata = base64.b64decode(imgstring)
imgfinal = open('here.jpg','wb')
imgfinal.write(imgdata)
root=Tk()
img = ImageTk.PhotoImage(Image.open(imgdata)) #This Doesn't work for me !
panel = Label(root,image=img)
panel.pack()
root.mainloop()
What I am trying to do is to add an image to the gui from the python script itself.
The imgstring variable is a shortened version of the actual image code.
The "here.jpg" file is a test used to make sure the code actually converts the imgdata bytes into an image.
Edit: -How can I add the image from its string to the label ?
-What should I change the line " img = ImageTk.PhotoImage.. " to ?