From f3266ef731d1f6056a5dec2cab7cdcfb18837ab3 Mon Sep 17 00:00:00 2001 From: Igor Tatarnikov Date: Wed, 24 Apr 2024 18:18:47 +0100 Subject: [PATCH] Added support for multiple file formats --- brainrender/render.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/brainrender/render.py b/brainrender/render.py index c23335f9..572b03c4 100644 --- a/brainrender/render.py +++ b/brainrender/render.py @@ -347,9 +347,11 @@ def screenshot(self, name=None, scale=None): self.render(interactive=False) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") - name = name or f"brainrender_screenshot_{timestamp}" - if ".png" not in name: - name += ".png" + name = Path(name or f"brainrender_screenshot_{timestamp}") + + # If no suffix is provided or it an unsupported format, default to .png + if name.suffix not in [".png", ".eps", ".pdf", ".svg", ".jpg"]: + name = name.with_suffix(".png") scale = scale or settings.SCREENSHOT_SCALE