我有一个二进制的PIL图像,我需要将其转换为RGB格式。我对这个图像进行了去斜处理。二进制图像 我需要这个方法: 我已经尝试过这个,但没有起作用。from PIL import Image as im img = im.fromarray((255 * Image).astype("uint8")).convert("RGB")
我仍然不明白如果需要 RGB 为什么要转换为 RGBA,但是这段代码会根据你的要求将图片转换为 RGB: #!/usr/local/bin/python3 import numpy as np from PIL import Image # Open input image im = Image.open('text.png').convert('RGB') # Invert npim = 255 - np.array(im) # Save Image.fromarray(npim).save('result.png')