From 8a7b7e598f7249c70ac0ccc18a421d5a07a4e917 Mon Sep 17 00:00:00 2001 From: pieterdd Date: Sat, 20 Dec 2025 13:37:45 +0100 Subject: [PATCH] Fix JPG export It was in the definition of supported file formats, but the export was hardcoded to PNG. --- gradia/graphics/image.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gradia/graphics/image.py b/gradia/graphics/image.py index 15c3e27..902880c 100644 --- a/gradia/graphics/image.py +++ b/gradia/graphics/image.py @@ -30,6 +30,7 @@ from gradia.graphics.background import Background from gradia.ui.widget.preset_button import ImagePresetButton from gradia.app_constants import PRESET_IMAGES +from gradia.app_constants import SUPPORTED_EXPORT_FORMATS class ImageBackground(Background): @property @@ -69,7 +70,13 @@ def load_image(self, path: str) -> None: def save_image_copy_async(self) -> None: def save_in_background(): if self.image: - self.image.save(self.SAVED_IMAGE_PATH, 'PNG') + _, extension = os.path.splitext(self.SAVED_IMAGE_PATH) + target_format = 'PNG' + for format in SUPPORTED_EXPORT_FORMATS: + if extension.lower() in format['extensions']: + target_format = format['shortname'] + break + self.image.save(self.SAVED_IMAGE_PATH, target_format) thread = threading.Thread(target=save_in_background, daemon=True) thread.start()