list icons

This commit is contained in:
j 2011-09-29 13:05:34 +00:00
commit 64e7a534a7
6 changed files with 106 additions and 24 deletions

View file

@ -16,15 +16,14 @@ from optparse import OptionParser
from ox.image import drawText, wrapText
import sys
static_root = os.path.join(os.path.dirname(__file__), '..', '..', 'static')
def render_list_icon(frames, icon):
icon_width = 256
icon_height = 256
icon_image = Image.new('RGBA', (icon_width, icon_height))
frame_height = icon_height / 4
frame_ratio = 4 / 3
frame_height = int(icon_height / 2)
frame_ratio = 1
frame_width = int(round(frame_height * frame_ratio))
for i, frame in enumerate(frames):
frame_image = Image.open(frame)
@ -38,8 +37,9 @@ def render_list_icon(frames, icon):
frame_image = frame_image.resize((frame_width_, int(frame_width_ / frame_image_ratio)), Image.ANTIALIAS)
top = int((frame_image.size[1] - frame_height) / 2)
frame_image = frame_image.crop((0, top, frame_width_, top + frame_height))
icon_image.paste(frame_image, (i % 3 * frame_width + (1 if i % 2 == 2 else 0), int(i / 3) * frame_height))
mask_image = Image.open(ox.path.join(static_root, 'png', 'icon.mask.png'))
icon_image.paste(frame_image, (i % 2 * frame_width + (1 if i % 2 == 2 else 0),
int(i / 2) * frame_height))
mask_image = Image.open(os.path.join(static_root, 'png', 'iconMask.png'))
mask_image = mask_image.resize((icon_width, icon_height))
icon_image.putalpha(mask_image)
icon_image.save(icon)
@ -47,7 +47,7 @@ def render_list_icon(frames, icon):
def main():
parser = OptionParser()
parser.add_option('-f', '--frames', dest='frames', help='Poster frames (image files to be read)', default='')
parser.add_option('-i', '--icon', dest='icon', help='Icon (image file to be written)')
parser.add_option('-o', '--icon', dest='icon', help='Icon (image file to be written)')
(options, args) = parser.parse_args()
if options.icon == None:
parser.print_help()
@ -55,7 +55,7 @@ def main():
frames = options.frames.replace(', ', ',').split(',')
render_list_icon(frames, opt.icon)
render_list_icon(frames, options.icon)
if __name__ == "__main__":
main()