示例#1
0
# @author   huizhan

import os

from logo import Logo

if __name__ == '__main__':

    store_root = './Logos/'

    logo = Logo()

    content = 'gea6'
    with open('./Workers/gea6.logo', 'r+') as f:
        layout = f.read().split('\n')
    logo.set_layout(layout)

    # get colors
    colors = os.listdir('./Colors/')
    colors = [color.split('.')[0] for color in \
        colors if color.split('.')[-1]=='jpg']

    for color in colors:
        logo.set_colors(color)

        logo_img = logo.draw()
        save_path = store_root + content + '/'
        img_name = color + '.bmp'
        if not os.path.exists(save_path): os.makedirs(save_path)
        logo_img.save(save_path + img_name)
示例#2
0

def save_fix_height(img, name, root='./Logos/', fixed_height=120):

    width, height = img.size
    width = int(width * fixed_height / height)
    size = (width, fixed_height)
    img = img.resize(size, Image.ANTIALIAS)
    if not os.path.exists(root): os.makedirs(root)
    img.save(root + name + '.bmp', quality=100)


if __name__ == '__main__':

    logo = Logo()

    # example 1
    logo.set_font('typography')
    logo.set_colors('Noon to Dusk')
    logo.set_content('curme')
    logo_img = logo.draw()
    save_fix_height(logo_img, 'example1')

    # example 2
    with open('./Workers/gea6.logo', 'r+') as f:
        layout = f.read().split('\n')
    logo.set_layout(layout)
    logo.set_colors('Sea Blue')
    logo_img = logo.draw()
    save_fix_height(logo_img, 'example2')