Skip to content
Advertisement

LookupError: ‘base64’ is not a text encoding; use codecs.decode() to handle arbitrary codecs

Its showing error LookupError: ‘base64’ is not a text encoding; use codecs.decode() to handle arbitrary codecs.

Last few lines when the execution stops are – thumbnail = resize(photo_data, 200, 200) File “/home/anurag/photoshare/app.py”, line 406, in resize image_string = StringIO(img.decode(‘base64’)) LookupError: ‘base64’ is not a text encoding; use codecs.decode() to handle arbitrary codecs

begin photo uploading code

photos uploaded using base64 encoding so they can be directly embeded in HTML

end photo uploading code

resizes if greater than (x,y) else returns original

Then there is another filefor image. from PIL import Image from io import StringIO from resizeimage import resizeimage import os, base64

Advertisement

Answer

You should import base64 instead of decoding the img with img.decode

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement