forked from ecceman/affinity
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconvert.py
More file actions
34 lines (24 loc) · 671 Bytes
/
convert.py
File metadata and controls
34 lines (24 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
"""
Script used to convert a bunch of SVG files to PNG
"""
from os import walk, mkdir
import pyvips
# sudo apt-get install libvips
# pip install pyvips
PATH = "svg/"
def main():
"""
All the action
"""
for (root, dirs, files) in walk(PATH):
for f in files:
if ".svg" in f:
try:
mkdir(path=f"{root}/png/")
except OSError:
pass
convert_file = pyvips.Image.thumbnail(f"{root}/{f}", 52, height=52)
convert_file.write_to_file(f"{root}/png/{f.replace('svg', 'png')}")
if __name__ == "__main__":
main()