Skip to content

Instantly share code, notes, and snippets.

@balidani
Last active August 29, 2015 13:58
Show Gist options
  • Save balidani/9999716 to your computer and use it in GitHub Desktop.
Save balidani/9999716 to your computer and use it in GitHub Desktop.
import Image
import sys
def chunks(data, n):
"Yield successive n-sized chunks from data"
for i in xrange(0, len(data), n):
yield data[i:i+n]
width = 2880
height = 5000 # some arbitrary height
img = Image.new('L', (width, height), 'white')
img_data = list(img.getdata())
bmp = open('crypted.bmp', 'rb').read()
white = bmp[0:16]
reverse_chunks = list(chunks(bmp, 16))[::-1]
for i, chunk in enumerate(reverse_chunks):
for j in range(i * 6, (i +1) * 6):
c = int(chunk == white) * 255
img_data[j] = c
img.putdata(img_data)
img.save('result.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment