Python的PIL库中的new方法

代码:
from PIL import Image
import matplotlib.pyplot as plt
img_b = Image.new("RGB",(32,32))#不指定color,则为黑色#000000
plt.imshow(img_b)
plt.show()
print(img_b.format)#python创建的图像,其格式为None
img_r = Image.new("RGB",(32,32),"red")
plt.imshow(img_r)
plt.show()
img_g = Image.new("RGB",(32,32),"#00FF00")
plt.imshow(img_g)
plt.show()

结果:

猜你喜欢

转载自blog.csdn.net/MiniCatTwo/article/details/80565694