From abd757fd3080da313888f6d5907886091104bd08 Mon Sep 17 00:00:00 2001 From: Diego Porres Date: Mon, 26 Jun 2023 14:12:31 +0200 Subject: [PATCH] Ignore the fourth channel/mask when saving an image The renderer returns a RGBA image, just save the first 3 channels to correctly save the image of the resulting edits. --- viz/capture_widget.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viz/capture_widget.py b/viz/capture_widget.py index 48e1373..a63be95 100644 --- a/viz/capture_widget.py +++ b/viz/capture_widget.py @@ -31,7 +31,6 @@ class CaptureWidget: viz = self.viz try: _height, _width, channels = image.shape - assert channels in [1, 3] assert image.dtype == np.uint8 os.makedirs(self.path, exist_ok=True) file_id = 0 @@ -43,7 +42,7 @@ class CaptureWidget: if channels == 1: pil_image = PIL.Image.fromarray(image[:, :, 0], 'L') else: - pil_image = PIL.Image.fromarray(image, 'RGB') + pil_image = PIL.Image.fromarray(image[:, :, :3], 'RGB') pil_image.save(os.path.join(self.path, f'{file_id:05d}.png')) except: viz.result.error = renderer.CapturedException()