I tried the below code
global img
f_types=[('Jpeg files',"*.jpeg")]
filename=filedialog.askopenfile(filetypes=f_types)
img=Image.open(filename)
it generates the below trace back
File "PS C:\Users\vinot\AppData\Local\Programs\Python\Python310> & C:/Users/vinot/AppData/Local/Programs/Python/Python310/python.exe c:/Users/vinot/AppData/Local/Programs/Python/Python310/TextractModuleTest-1.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\vinot\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 1921, in __call__
return self.func(*args)
File "c:\Users\vinot\AppData\Local\Programs\Python\Python310\TextractModuleTest-1.py", line 15, in <lambda>
width=30, command=lambda:upload_file())
File "c:\Users\vinot\AppData\Local\Programs\Python\Python310\TextractModuleTest-1.py", line 21, in upload_file
img=Image.open(filename)
File "C:\Users\vinot\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py", line 3077, in open
prefix = fp.read(16)
File "C:\Users\vinot\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 70: character maps to <undefined>
I understand it's an encode error. I need help to solve this.