dotfiles/awesome/icons/svgs/svg_to_png.py

16 lines
458 B
Python
Executable File

#!/usr/bin/env python3
import pathlib
from cairosvg import svg2png
from PIL import Image, ImageOps
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=12, output_height=12)
with Image.open(png) as img:
img.load()
border_img = ImageOps.expand(img, 4, (0, 0, 0, 0))
border_img.save(png)
print(' Done')