Instantly share code, notes, and snippets.

Embed
What would you like to do?
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