Skip to content

Instantly share code, notes, and snippets.

@streety
Created March 16, 2012 10:44
Show Gist options
  • Select an option

  • Save streety/2049532 to your computer and use it in GitHub Desktop.

Select an option

Save streety/2049532 to your computer and use it in GitHub Desktop.
Cycle through all 16 million possible RGB colors and display them in an image
#!/usr/bin/env python
from PIL import Image
import itertools
import sys
import time
def gen_image():
im = Image.new('RGB', (4096,4096))
pix = im.load()
g = itertools.product(range(256), repeat=3)
for i in range(4096):
for j in range(4096):
pix[i,j] = g.next()
return im
def timeit(func):
start = time.time()
result = func()
end = time.time()
print end - start, 's'
return result
if __name__ == '__main__':
im = timeit(gen_image)
im.save(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment