Created
February 7, 2012 09:37
-
-
Save Leonidas-from-XIV/1758713 to your computer and use it in GitHub Desktop.
Generator for random JPEG images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
# -*- coding: utf-8 -*- | |
from itertools import izip | |
from datetime import datetime | |
from PIL import Image | |
from numpy.random import randint | |
x, y = 2560, 1920 | |
def grouper(n, iterable): | |
args = [iter(iterable)] * n | |
return izip(*args) | |
def rndnumpy(pixels): | |
rand = randint(0, 255, pixels*3) | |
return grouper(3, rand) | |
img = Image.new('RGB', (x, y)) | |
img.putdata(list(rndnumpy(x*y))) | |
img.save(datetime.now().strftime('IMG_%Y%m%d_%H%M%S.jpg')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment