mirror of https://github.com/Riesi/frog_emojis.git
[misc] implement subfolder handling for python tool
This commit is contained in:
parent
4e0e857914
commit
d5f1f068af
18
gen_png.py
18
gen_png.py
|
@ -24,8 +24,15 @@ def raster_graphics(files):
|
||||||
print('\n------------------------------\n'+ str(frogs) + ' remaining...\nRastering ' + str(name)+'\n')
|
print('\n------------------------------\n'+ str(frogs) + ' remaining...\nRastering ' + str(name)+'\n')
|
||||||
frogs = frogs - 1
|
frogs = frogs - 1
|
||||||
for s in sizes:
|
for s in sizes:
|
||||||
subprocess.run(["inkscape", f, "-C", "-w", str(s), "--export-filename=./png/fixed_width/"+str(s)+"/"+name+".png"],timeout=30)
|
# make sure the subdirectories exist
|
||||||
subprocess.run(["inkscape", f, "-C", "-h", str(s), "--export-filename=./png/fixed_height/"+str(s)+"/"+name+".png"],timeout=30)
|
width_path = "./png/fixed_width/"+str(s)+"/"+str(os.path.dirname(f.removeprefix('svg/').removesuffix('.svg')))
|
||||||
|
height_path = "./png/fixed_height/"+str(s)+"/"+str(os.path.dirname(f.removeprefix('svg/').removesuffix('.svg')))
|
||||||
|
if not( os.path.exists(width_path) and os.path.exists(height_path) ):
|
||||||
|
os.makedirs(width_path ,exist_ok=True)
|
||||||
|
os.makedirs(height_path ,exist_ok=True)
|
||||||
|
# invoke Inkscape to raster the given vector graphics
|
||||||
|
subprocess.run(["inkscape", f, "-C", "-w", str(s), "--export-filename="+str(width_path)+"/"+name+".png"],timeout=30)
|
||||||
|
subprocess.run(["inkscape", f, "-C", "-h", str(s), "--export-filename="+str(height_path)+"/"+name+".png"],timeout=30)
|
||||||
|
|
||||||
# git add given files
|
# git add given files
|
||||||
def git_add_raster(files):
|
def git_add_raster(files):
|
||||||
|
@ -92,10 +99,11 @@ if len(sys.argv) == 1:
|
||||||
create_tag()
|
create_tag()
|
||||||
else:
|
else:
|
||||||
if sys.argv[1] == 'all':
|
if sys.argv[1] == 'all':
|
||||||
files = [f for f in glob.glob("./svg**/*.svg", recursive=True)]
|
files = [f for f in glob.glob("svg**/*.svg", recursive=True)]
|
||||||
else:
|
else:
|
||||||
for f in sys.argv:
|
for f in sys.argv:
|
||||||
if os.path.exists("./svg/"+f+".svg"):
|
f = f.removeprefix('svg/').removesuffix('.svg')
|
||||||
files.append("./svg/"+f+".svg")
|
if os.path.exists("svg/"+f+".svg"):
|
||||||
|
files.append("svg/"+f+".svg")
|
||||||
raster_graphics(files)
|
raster_graphics(files)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue