From 94489b5da2864f7adbea5ad59fce7bffedf28457 Mon Sep 17 00:00:00 2001 From: julius Date: Sun, 27 Oct 2024 20:09:57 +0100 Subject: [PATCH] enable other image formats API --- speckles.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/speckles.py b/speckles.py index b171c85..45f6f3e 100644 --- a/speckles.py +++ b/speckles.py @@ -293,8 +293,12 @@ def make_wallpaper( image.write_to_file(filename) return filename elif fileformat: - buf = io.BytesIO(content.as_str().encode("utf-8")) - buf.seek(0) + if fileformat == "svg": + buf = io.BytesIO(content.as_str().encode("utf-8")) + buf.seek(0) + else: + with pyvips.Image.svgload_buffer(content.as_str().encode("utf-8")) as image: + buf = image.write_to_buffer(fileformat) return StreamingResponse(content=buf, media_type=MEDIA_TYPES[fileformat])