Skip to content

Commit

Permalink
Ignore the fourth channel/mask when saving an image
Browse files Browse the repository at this point in the history
The renderer returns a RGBA image, just save the first 3 channels to correctly save the image of the resulting edits.
  • Loading branch information
PDillis authored Jun 26, 2023
1 parent d7f7319 commit abd757f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions viz/capture_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def dump_png(self, image):
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
Expand All @@ -43,7 +42,7 @@ def dump_png(self, image):
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()
Expand Down

0 comments on commit abd757f

Please sign in to comment.