34
loading...
This website collects cookies to deliver better user experience
import base64
import io
from PIL import Image
def read_string():
with open("tux.jpg", "rb") as image:
image_string = base64.b64encode(image.read())
return image_string
if __name__ == "__main__":
base64_string = read_string()
print(base64_string)
b'/9j/4AAQSkZJRgABAQAAAQABAAD/7QBsUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAE8cAVoAAxslRxwCAAACAAAcAnQAO8KpIFNvZmlhWW91c2hpIC0gaHR0cDovL3d3dy5yZWRidWJibGUuY29tL3Blb3BsZS9zb2ZpYXlvdXNoAP/bAEMAAwICAwICAwMDAwQDAwQFCAUFBAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQ
....
/5W09f+V+gfFfqHxX6h8V+ofFfqHxX6h8V+ofFfvHxX7x8V+8fFfvHxU6Y9FblW4A0P8Aj2//2Q=='
def decode_base64():
base64_string = read_string()
decoded_string = io.BytesIO(base64.b64decode(base64_string))
img = Image.open(decoded_string)
return img.show()
if __name__ == "__main__":
decode_base64()
import base64
import io
from PIL import Image
def read_string():
with open("tux.jpg", "rb") as image:
image_string = base64.b64encode(image.read())
return image_string
def decode_base64():
base64_string = read_string()
decoded_string = io.BytesIO(base64.b64decode(base64_string))
img = Image.open(decoded_string)
return img.show()
if __name__ == "__main__":
base64_string = read_string()
print(base64_string)
decode_base64()