# inspired by # http://www.johnsadowski.com/big_spanish_castle.php import os, sys from PIL import Image, ImageOps try: filename = sys.argv[1] except IndexError: sys.exit("usage: makeillusion.py ") basename = os.path.splitext(os.path.basename(filename))[0] im = Image.open(sys.argv[1]) y, cr, cb = im.convert("YCbCr").split() # luminance y.save(basename + "-2.jpg") # inverted color content y = Image.new("L", y.size, 128) im = Image.merge("YCbCr", (y, cr, cb)).convert("RGB") im = ImageOps.autocontrast(ImageOps.invert(im)) x = im.size[0]/2 y = im.size[1]/2 # draw a dot to focus on im.paste("black", (x-1, y-1, x+1, y+1)) im.save(basename + "-1.jpg") print """ """ % (basename, basename, basename, im.size[0], im.size[1])