save as different image formats (pyvips)
This commit is contained in:
parent
9f5bb724cb
commit
0ee3e39c3c
11
speckles.py
11
speckles.py
@ -1,5 +1,6 @@
|
|||||||
import itertools
|
import itertools
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import pyvips
|
||||||
import logging
|
import logging
|
||||||
from perlin import CoordsGenerator
|
from perlin import CoordsGenerator
|
||||||
import svg
|
import svg
|
||||||
@ -253,8 +254,12 @@ def make_wallpaper(
|
|||||||
)
|
)
|
||||||
|
|
||||||
content = svg.SVG(width=x, height=y, elements=elements)
|
content = svg.SVG(width=x, height=y, elements=elements)
|
||||||
with open(filename, "wt") as f:
|
if Path(filename).suffix == ".svg":
|
||||||
f.write(content.as_str())
|
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__":
|
if __name__ == "__main__":
|
||||||
@ -285,7 +290,7 @@ if __name__ == "__main__":
|
|||||||
make_wallpaper(
|
make_wallpaper(
|
||||||
",".join(["#000000"] + palettes[0]["colours"]),
|
",".join(["#000000"] + palettes[0]["colours"]),
|
||||||
orientation="2880x1920",
|
orientation="2880x1920",
|
||||||
filename="testing.svg",
|
filename="testing.png",
|
||||||
markers="tY.",
|
markers="tY.",
|
||||||
size=3,
|
size=3,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user