#!/usr/bin/env python3 import pathlib from cairosvg import svg2png from PIL import Image, ImageOps SIZE = 100 part_size = SIZE//5 for svg in pathlib.Path('.').glob('*.svg'): print(f'Converting {svg.name}...', end='') png = svg.with_suffix('.png') svg2png(url=str(svg), write_to=str(png), output_width=part_size*3, output_height=part_size*3) with Image.open(png) as img: img.load() border_img = ImageOps.expand(img, part_size, (0, 0, 0, 0)) border_img.save(png) print(' Done')