Last active
August 29, 2015 13:58
-
-
Save balidani/9999716 to your computer and use it in GitHub Desktop.
This file contains 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
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