【发布时间】:2022-08-21 04:07:45
【问题描述】:
我尝试创建由两列组成的非常简单的图像——一列绿色,另一列红色,但是当我运行如下所示的脚本时,我得到了其他颜色的图像。 知道为什么会这样吗?
from PIL import Image
list=[(0,255,00),(255,0,0),(0,255,00),(255,0,0),(0,255,00),(255,0,0)]
a=Image.new(\'RGB\',(2,3), \"white\")
a.putdata(list)
a.save(\'my_picture.jpg\')
我得到的图像: enter image description here
-
顺便说一句,不要将变量命名为与预定义的 Python 变量相同的名称(例如,本例中的
list)。
标签: python image python-imaging-library rgb