最好使用Python图像库来执行此操作,恐怕这是单独下载的。
执行所需操作的最简单方法是通过Image对象上的load()方法,该方法返回一个像素访问对象,您可以像数组一样对其进行操作:
from PIL import Imageim = Image.open('dead_parrot.jpg') # Can be many different formats.pix = im.load()print im.size # Get the width and hight of the image for iterating overprint pix[x,y] # Get the RGBA Value of the a pixel of an imagepix[x,y] = value # Set the RGBA Value of the image (tuple)im.save('alive_parrot.png') # Save the modified pixels as .png或者,查看ImageDraw,它提供了更丰富的API用于创建图像。



