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.
pull/65/head
Diego Porres 2 years ago committed by GitHub
parent d7f7319972
commit abd757fd30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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()

Loading…
Cancel
Save