Python script I wrote a while back that outputs random images. PIL must be installed to work. Change |file_name| accordingly. JPEG images can be up to 65535 x 65535 in size, which are the max values for |width| and |height|. It's not optimized, so keep the resolution small unless you want to wait a while.<p>It'll output images that look like this: <a href="http://dave-gallagher.net/pics/666x666.png" rel="nofollow">http://dave-gallagher.net/pics/666x666.png</a><p><pre><code> from PIL import Image, ImageDraw
from random import randint
def random_image():
width = 666
height = 666
file_name = '/Users/Dave/%dx%d' % (width, height)
path_png = file_name + '.png'
path_jpg = file_name + '.jpg'
path_bmp = file_name + '.bmp'
path_tif = file_name + '.tif'
img = Image.new("RGB", (width, height), "#FFFFFF")
draw = ImageDraw.Draw(img)
for height_pixel in range(height):
if height_pixel % 100 is 0:
print height_pixel
for width_pixel in range(width):
r = randint(0, 255)
g = randint(0, 255)
b = randint(0, 255)
dr = (randint(0, 255) - r) / 300.0
dg = (randint(0, 255) - g) / 300.0
db = (randint(0, 255) - b) / 300.0
r = r + dr
g = g + dg
b = b + db
draw.line((width_pixel, height_pixel, width_pixel, height_pixel), fill=(int(r), int(g), int(b)))
img.save(fp=path_png, format="PNG")
img.save(fp=path_jpg, format="JPEG", quality=95, subsampling=0) # 100 quality is 2x to 3x file size, but you won't see a difference visually.
img.save(fp=path_bmp, format="BMP")
img.save(fp=path_tif, format="TIFF")
if __name__ == "__main__":
random_image()</code></pre>