Skip to content

BYTE in image #7592

Answered by radarhere
babaevgusein2009 asked this question in Q&A
Dec 1, 2023 · 5 comments · 2 replies
Discussion options

You must be logged in to vote

Thanks. So, there is a problem here in how you are passing the image data to Pillow.

Your code attempts to decode base64-encoded data with base64.b64decode(byte_data) - but the data that you posted is not base64 encoded.

You should also be aware that you cannot copy and paste the bytes that you have into input() and have Python get bytes as a result. If I try and paste in a shorter example,

>>> byte_data = input()
b'\xff\xd8'
>>> byte_data
"b'\\xff\\xd8'"
>>> byte_data = input()
\xff\xd8
>>> byte_data
'\\xff\\xd8'

neither of those attempts becomes b'\xff\xd8'

Maybe your intention was to base64 encode the bytes, so that you could paste that into input(). To base64 encode a variable, you ca…

Replies: 5 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@babaevgusein2009
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by radarhere
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@radarhere
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants