当前位置:主页 > 软件编程 > Python代码 >

python使用PIL模块获取图片像素点的方法

时间:2021-03-28 09:15:27 | 栏目:Python代码 | 点击:

如下所示:

from PIL import Image
########获取图片指定像素点的像素
def getPngPix(pngPath = "aa.png",pixelX = 1,pixelY = 1):
    img_src = Image.open(pngPath)
    img_src = img_src.convert('RGBA')
    str_strlist = img_src.load()
    data = str_strlist[pixelX,pixelY]
    img_src.close()
    return data


print(getPngPix())

您可能感兴趣的文章:

相关文章