【发布时间】:2018-09-15 22:24:18
【问题描述】:
我有以下代码:
from PIL import Image
import numpy as np
a = np.ones((512, 256, 3)).astype(int)*255
image = Image.fromarray(a, "RGB")
image.save("test.png", "PNG")
我希望这会产生尺寸为 512x256 的白色图像。 相反,我得到了这个:
由于某种原因,此图像是一系列条形而不是纯色。
我做错了什么?是numpy数组的格式吗?
【问题讨论】:
标签: python python-3.x image numpy python-imaging-library