Skip to content

Instantly share code, notes, and snippets.

@kezzyhko
Last active November 2, 2024 18:32
Show Gist options
  • Select an option

  • Save kezzyhko/ea5dcfd97be881d200e694731cb0c257 to your computer and use it in GitHub Desktop.

Select an option

Save kezzyhko/ea5dcfd97be881d200e694731cb0c257 to your computer and use it in GitHub Desktop.
Tool for decoding binary messages from a screenshot of github's yearly commit chart [Dev Detour rickroll]
from PIL import Image
DELTA_X = 17
DELTA_Y = 17
START_X = 10
START_Y = 10
# https://stackoverflow.com/a/138260/6702274
im = Image.open('Untitled.png')
pix = im.load()
x = START_X
y = START_Y
c = 0
bits = ""
string = ""
while c < 1000:
if x > im.size[0]:
x = START_X
y += DELTA_Y
if y > im.size[1]:
break
color_red = pix[x, y][0]
bit = "0" if color_red > 150 else "1"
bits += bit
if bits == "00000000":
break
if len(bits) == 8:
string += chr(int(bits, 2))
bits = ""
x += DELTA_X
c += 1
print(string)
@kezzyhko
Copy link
Author

kezzyhko commented Nov 2, 2024

Made for decoding a screenshot from this Dev Detour's video
https://youtu.be/_aDvNg9F6w8?t=178
It turned out to be a rickroll. Of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment