Created
July 22, 2013 09:50
-
-
Save luca-m/6052684 to your computer and use it in GitHub Desktop.
Simple script for xorring toghether all layers of a GIF image. This work with indexed image, working with multi-channel images could need some modifications.
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
#!/usr/bin/env python | |
import Image | |
import sys | |
def xorImage( infile ): | |
try: | |
im = Image.open( infile ) | |
except IOError: | |
print "Cant load", infile | |
sys.exit(1) | |
(w,h) = im.size | |
ss = [ [0]*w for x in range(h) ] | |
try: | |
while 1: | |
m = im.load() | |
for y in range(h): | |
for x in range(w): | |
ss[y][x] ^= m[x,y] | |
im.seek( im.tell() + 1 ) | |
except EOFError: | |
im.seek(0) | |
m=im.load() | |
for y in range(h): | |
for x in range(w): | |
m[x,y]=ss[y][x] | |
im.save(infile+'-xor.bmp') | |
if __name__ == "__main__": | |
if len(sys.argv) < 2 : | |
print "GIF image xorrer. Xor all the layer of the image." | |
print "\tUsage %s <imagefile>" % sys.argv[0] | |
exit(-1) | |
xorImage(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment