Created
July 27, 2011 09:26
-
-
Save revolunet/1109000 to your computer and use it in GitHub Desktop.
generates PNG images from sizes
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
| import Image, ImageDraw, ImageFont | |
| import os | |
| def createImage(width=100, height=50): | |
| size = (width, height) | |
| im = Image.new('RGB', size) | |
| draw = ImageDraw.Draw(im) | |
| color = (100,100,100) | |
| text = "%sx%s" % (width, height) | |
| outFile='%s.png' % text | |
| font = ImageFont.truetype("arial.ttf", 45) | |
| tsize = font.getsize(text) | |
| # center text on image | |
| text_pos = ((width-tsize[0])/2,(height-tsize[1])/2) | |
| draw.text(text_pos, text, fill=color, font=font) | |
| del draw | |
| im.save(outFile, 'PNG') | |
| os.chdir('c:\\users\\juju\\desktop\\img') | |
| # iPad | |
| createImage(1024, 748) | |
| createImage(1024, 690) | |
| createImage(768, 1004) | |
| createImage(768, 946) | |
| # Xoom | |
| createImage(1280, 696) | |
| createImage(1280, 648) | |
| createImage(800, 1176) | |
| createImage(800, 1128) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment