from math import ceil
from PIL import Image, ImageDraw
WIDTH_IN_BYTE = 2
TEXT = ""
zero = Image.open('sad.png')
one = Image.open('happy.png')
crts = len(TEXT)
width = zero.width
height = zero.height
columns = WIDTH_IN_BYTE*8
rows = ceil(crts/WIDTH_IN_BYTE)
img = Image.new('RGB', (width*columns, height*rows), (255,255,255))
for r in range(rows):
for c in range(len(TEXT[r*WIDTH_IN_BYTE:(r+1)*WIDTH_IN_BYTE])):
letter = int.from_bytes(TEXT[r*WIDTH_IN_BYTE + c].encode(), 'big')
for i in range(8):
img.paste(one if (letter >> (7-i) & 1) else zero, ((c*8+i)*width, r*height))
img.save('result.png', 'PNG')
Not being terribly familiar with either of those for image processing, I'd probably give myself a crash-course on drawing images onto an html5 canvas. That's an API I've at least skimmed over before.
EDIT: I messed up the xxd command. I'm looking to fix it now. EDIT 2: Fixed. I inserted a cut command to extract the fields. There might be a better way.
110
u/[deleted] Jan 11 '20 edited Jan 11 '20
{Hitoribocchi no ○○ Seikatsu}
and
175
u/bucket3432 Jan 11 '20
Binary to ASCII
Answer: "epstein didn't kill himself."
25
u/DataRecoveryMan Jan 11 '20
Yeah, I'd have gotten stuck on the "python or node?" debate for long enough to eat an hour either way.
2
u/[deleted] Jan 12 '20
Would you care to join r/bocchi
2
u/HeyThereCharlie Jan 20 '20
Your username is offensive to my culture