diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..e4be8bd --- /dev/null +++ b/config.toml @@ -0,0 +1,2 @@ +raster_images = true +raster_size = 512 \ No newline at end of file diff --git a/src/main.py b/src/main.py index 413f16a..db1ea03 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,6 @@ from svgutils.compose import * from cairosvg import svg2png -import toml +import toml, os CONFIG["svg.file_path"] = "../assets/" @@ -8,6 +8,11 @@ with open("../definitions.toml", "r") as def_file: definitions = toml.loads(def_file.read()) with open("../designs.toml", "r") as design_file: designs = toml.loads(design_file.read()) +with open("../config.toml", "r") as config_file: + config = toml.loads(config_file.read()) + +os.makedirs("../output/vector/", exist_ok=True) +os.makedirs("../output/" + str(config["raster_size"]) + "/", exist_ok=True) partsList = [] for key in designs: @@ -18,11 +23,12 @@ for key in designs: svg_parts = [] for part in partsList: svg_parts.append(SVG(part)) - Figure( - "128", - "128", - *svg_parts, - SVG("credits.svg") - ).save("../output/vector/"+key+".svg") - svg2png(url="../output/vector/"+key+".svg", write_to="../output/512/"+key+".png", output_width=512) + Figure("128","128", *svg_parts, SVG("credits.svg")).save("../output/vector/" + key + ".svg") + + if config["raster_images"]: + svg2png( + url="../output/vector/" + key + ".svg", + write_to="../output/" + str(config["raster_size"]) + "/" + key + ".png", output_width=config["raster_size"] + ) + print("Done!") \ No newline at end of file