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