Skip to content

Instantly share code, notes, and snippets.

@im-denisenko
Created February 8, 2015 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save im-denisenko/35b7897d3e511905b28d to your computer and use it in GitHub Desktop.
Save im-denisenko/35b7897d3e511905b28d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from PIL import Image
import binascii
import numpy as np
# Read image and convert pixels to array
im = Image.open('/home/someone/Downloads/picture.png')
matrix = np.array(im)
# Convert array to binary string (excluding red borders)
message = '0b'
for row in matrix:
for item in row:
if item in (0, 1):
message += str(item)
# Convert binary string to ascii
message = binascii.unhexlify('%x' % int(message, 2))
# And print result...
print message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment