Skip to content

Instantly share code, notes, and snippets.

@stephanie-w
Last active July 2, 2025 09:22
Show Gist options
  • Select an option

  • Save stephanie-w/7c7c8702ffac936dc557320fa3fc3ba3 to your computer and use it in GitHub Desktop.

Select an option

Save stephanie-w/7c7c8702ffac936dc557320fa3fc3ba3 to your computer and use it in GitHub Desktop.
from PIL import Image
import numpy as np
with Image.open("cover-secret.png") as img:
width, height = img.size
data = np.array(img)
data = np.reshape(data, width*height*3)
# extract lsb
data = data & 1
# Packs binary-valued array into 8-bits array.
data = np.packbits(data)
# Read and convert integer to Unicode characters until hitting a non-printable character
for x in data:
l = chr(x)
if not l.isprintable():
break
print(l, end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment