Skip to content

Instantly share code, notes, and snippets.

@foota
Created May 13, 2012 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foota/2689099 to your computer and use it in GitHub Desktop.
Save foota/2689099 to your computer and use it in GitHub Desktop.
Image file from tetration fractal data
#!/usr/bin/env python
import sys, os
from PIL import Image
def main(args):
if len(args) < 3:
print >>sys.stderr, "Usage: %s datafile imagefile" % os.path.basename(args[0])
sys.exit(1)
datafile, imagefile = args[1:3]
f = file(datafile)
sw, sh = map(int, f.readline().strip().split())
im = Image.new("RGB", (sw, sh))
for y, l in enumerate(f):
for x, data in enumerate(map(int, l.strip().split())):
rgb = (data % 4 * 64, data % 8 * 32, data % 16 * 16)
im.putpixel((x, y), rgb)
#im.show()
im.save(imagefile)
if __name__ == "__main__": main(sys.argv)
@foota
Copy link
Author

foota commented May 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment