0

i have a string that looks like this b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01' (it's way too long to put it all here)

the string contains the bytes of an images and i want to display that image.

image_data = tt # byte values of the image
image = Image.open(io.BytesIO(image_data))
image.show()

when I try to display the image i get an TypeError: a bytes-like object is required, not 'str'

how do I display the image from a string?

  • Does this answer your question? [TypeError: a bytes-like object is required, not 'str' when writing to a file in Python 3](https://stackoverflow.com/questions/33054527/typeerror-a-bytes-like-object-is-required-not-str-when-writing-to-a-file-in) – Azhar Khan Oct 14 '22 at 09:06

0 Answers0