Skip to content

Instantly share code, notes, and snippets.

@miek
Created March 6, 2016 19:09
Show Gist options
  • Save miek/25eeb17b74c6a8d0a22b to your computer and use it in GitHub Desktop.
Save miek/25eeb17b74c6a8d0a22b to your computer and use it in GitHub Desktop.
from PIL import Image
import struct
import sys
imgsize = 128
img = Image.new('L', (imgsize, imgsize))
with open("lily.cfile", "rb") as f:
while True:
sample = f.read(8)
if sample:
csample = [(x + 1) / 2 for x in struct.unpack("ff", sample)]
(x, y) = [int(imgsize * x) for x in csample]
img.putpixel((x, y), img.getpixel((x, y)) + 1)
else:
break
img.save('out.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment