I am trying to invert an image using PIL.ImageOps.invert(image), however I am receiving the following error: AttributeError: 'str' object has no attribute
'mode'
Here is my code:
# allows user to select image file from local
photo = filedialog.askopenfilename(initialdir="/", title="Select file", filetypes=(("png files", "*.png"), ("all files", "*.*")))
print(photo)
# creates canvas to display the image
canvas = Canvas(width=400, height=400)
canvas.pack()
inverted_image = PIL.ImageOps.invert(photo)
# reference to image object so it doesn't blanks it
label = Label(image=inverted_image)
label.image = inverted_image
canvas.create_image(200, 200, image=inverted_image, anchor=CENTER)
What I am trying to do here is to invert the image that was selected by the user and display it. I've seen others with similar problem but I have yet to see one with 'mode' error (maybe I missed it).