Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 10th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/env python2
  2. # -*- coding: utf-8 -*-
  3. from itertools import izip
  4. from datetime import datetime
  5.  
  6. from PIL import Image
  7. from numpy.random import randint
  8.  
  9. x, y = 2560, 1920
  10.  
  11. def grouper(n, iterable):
  12.     args = [iter(iterable)] * n
  13.     return izip(*args)
  14.  
  15. def rndnumpy(pixels):
  16.     rand = randint(0, 255, pixels*3)
  17.     return grouper(3, rand)
  18.  
  19. img = Image.new('RGB', (x, y))
  20. img.putdata(list(rndnumpy(x*y)))
  21. img.save(datetime.now().strftime('IMG_%Y%m%d_%H%M%S.jpg'))