fork download
  1.  
Success #stdin #stdout 0.03s 9640KB
stdin
import numpy as np
from PIL import Image

def encode_image(img):
img_array = np.array(img)
ascii_str = ""
for row in img_array:
for pixel in row:
ascii_str += chr(pixel[0]) + chr(pixel[1]) + chr(pixel[2])
return ascii_str

def decode_ascii(ascii_str):
# Convert ASCII string back into a list of integers
ints = [ord(c) for c in ascii_str]

# Reshape the list of integers into a 3D array representing the image
width = 1920
height = 1080
channel_count = 3
img_array = np.reshape(ints, (height, width, channel_count))

# Create a Pillow Image object from the NumPy array
img = Image.fromarray(np.uint8(img_array))

return img

ascii_str = "jpxrPjxvPjy9Pjz9Pj1+Pj2+Pj3+Pj4+Pj5+Pj6+Pj7+P
stdout
Standard output is empty