Skip to content

Commit 888627f

Browse files
committed
Make rasterize script more robust. Move scripts to project root.
1 parent bc0d4ac commit 888627f

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed
File renamed without changes.

img/rasterize.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

rasterize.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
import subprocess
3+
import re
4+
5+
# This script converts SVG images into PNG.
6+
# Requires Python 3, Inkscape and pngquant.
7+
8+
self_dir = os.path.dirname(__file__)
9+
img_dir = os.path.join(self_dir, "img")
10+
11+
for svg_name in os.listdir(img_dir):
12+
svg_path = os.path.join(img_dir, svg_name)
13+
base, ext = os.path.splitext(svg_name)
14+
if ext == ".svg":
15+
png_name = "{0}.png".format(base)
16+
png_path = os.path.join(img_dir, png_name)
17+
if not os.path.exists(png_path) or os.path.getmtime(svg_path) > os.path.getmtime(png_path):
18+
print(svg_name)
19+
subprocess.run(["inkscape", "-z", "-e", png_path, "-d", "192", svg_path])
20+
subprocess.run(["pngquant", "--ext", ".png", "--force", "--skip-if-larger", "--strip", png_path])

0 commit comments

Comments
 (0)