Home > Enterprise >  PIL Image.save() convert does'nt maintain RGB color
PIL Image.save() convert does'nt maintain RGB color

Time:01-01

I am trying to save a numpy array as RGB image using PIL.Image.save(),but it the saved image is not RGB. How do I save the image as RGB ? I am receiving the image as numpy array.

image_with_detections = np.array(image_with_detections)
image = Image.fromarray(image_with_detections.astype('uint8'), 'RGB')
image.save(save_path)

The link to original image The link to image saved by Image.save()

CodePudding user response:

You can do something like the following

image_with_detections = np.array(image_with_detections)
image = Image.fromarray(image_with_detections.astype('uint8'), 'RGB')
image = image[:,:,::-1]
image.save(save_path)
  • Related