下面代码可以帮助快速改变图片的像素值.
file_in : 要改变图片的地址
width:宽度
height:高度
file_out : 输出地址
需要安装的第三方库:PIL
from PIL import Image
def produceImage(file_in, width, height, file_out):
image = Image.open(file_in)
resized_image = image.resize((width, height), Image.ANTIALIAS)
resized_image.save(file_out)
if __name__ == '__main__':
file_in = 'D:\图片\人物照\灰色领带证件照.jpg'
width = 300
height = 450
file_out = 'D:\图片\人物照\证件照_300x450.jpg'
produceImage(file_in, width, height, file_out)