diff --git a/speckles.py b/speckles.py index a53a723..de3b31f 100644 --- a/speckles.py +++ b/speckles.py @@ -1,5 +1,6 @@ import itertools from pathlib import Path +import pyvips import logging from perlin import CoordsGenerator import svg @@ -253,8 +254,12 @@ def make_wallpaper( ) content = svg.SVG(width=x, height=y, elements=elements) - with open(filename, "wt") as f: - f.write(content.as_str()) + if Path(filename).suffix == ".svg": + with open(filename, "wt") as f: + f.write(content.as_str()) + else: + with pyvips.Image.svgload_buffer(content.as_str().encode("utf-8")) as image: + image.write_to_file(filename) if __name__ == "__main__": @@ -285,7 +290,7 @@ if __name__ == "__main__": make_wallpaper( ",".join(["#000000"] + palettes[0]["colours"]), orientation="2880x1920", - filename="testing.svg", + filename="testing.png", markers="tY.", size=3, )