Created
November 24, 2011 00:58
-
-
Save giginet/1390387 to your computer and use it in GitHub Desktop.
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
| # -*- coding: utf-8 -*- | |
| # | |
| # ng.py | |
| # created by giginet on 2011/10/23 | |
| # | |
| import os | |
| import random | |
| from PIL import Image | |
| templates = [Image.open('templates/type%d.png' % i).convert('RGBA') for i in xrange(1, 5)] | |
| for i in xrange(3000): | |
| template = random.choice(templates) | |
| xscale = 0.3 + random.random()*1 | |
| yscale = 0.3 + random.random()*1.5 | |
| rotate = random.randint(0, 360) | |
| img = template.copy() | |
| img = img.rotate(rotate, expand=1) | |
| size = map(lambda x: int(x), (xscale * 150, yscale * 300)) | |
| img = img.resize(size) | |
| background = Image.new("RGBA", (150, 300), (255,) * 4) | |
| background.paste(img, (0, 0)) | |
| filename = 'ng%d.png' % i | |
| background.save(os.path.join('templates/ng/', filename)) | |
| print "templates/ng/%s" % filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment