from base64 import b64encode
from os import listdir
from setting import IMAGES_FOLDER
header = """"""
start_tag = """
"""
for filename in listdir('{}/team/'.format(IMAGES_FOLDER)):
if filename[-4:] == '.png':
png_name = '{}/team/{}'.format(IMAGES_FOLDER, filename)
with open(png_name, 'rb') as png_file:
b64res = b64encode(png_file.read()).decode()
image_tag = """
"""
for size in (30, 50, 80):
svg_name = '{}/team/h{}-'.format(IMAGES_FOLDER, size) + filename.replace('.png', '.svg')
svg_res = header + start_tag.format(size=size) + image_tag.format(size=size, b64res=b64res) + end_tag
with open(svg_name, 'w') as svg_file:
svg_file.write(svg_res)
for filename in listdir('{}/league/'.format(IMAGES_FOLDER)):
if filename[-4:] == '.png':
png_name = '{}/league/{}'.format(IMAGES_FOLDER, filename)
with open(png_name, 'rb') as png_file:
b64res = b64encode(png_file.read()).decode()
image_tag = """
"""
for size in (35, 50, 80):
svg_name = '{}/league/h{}-'.format(IMAGES_FOLDER, size) + filename.replace('.png', '.svg')
svg_res = header + start_tag.format(size=size) + image_tag.format(size=size, b64res=b64res) + end_tag
with open(svg_name, 'w') as svg_file:
svg_file.write(svg_res)
for filename in listdir('{}/logo/'.format(IMAGES_FOLDER)):
if filename == 'bob-logo.png':
png_name = '{}/logo/{}'.format(IMAGES_FOLDER, filename)
with open(png_name, 'rb') as png_file:
b64res = b64encode(png_file.read()).decode()
image_tag = """
"""
for size in (40, 110):
svg_name = '{}/logo/h{}-'.format(IMAGES_FOLDER, size) + filename.replace('.png', '.svg')
svg_res = header + start_tag.format(size=size) + image_tag.format(size=size, b64res=b64res) + end_tag
with open(svg_name, 'w') as svg_file:
svg_file.write(svg_res)