Last active
July 2, 2025 09:22
-
-
Save stephanie-w/7c7c8702ffac936dc557320fa3fc3ba3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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