Python-修改图片分辨率
在图像识别的时候出现了手机拍摄的照片作为测试数据太大的情况,创建了这样一个代码来修改一下拍摄的图片的分辨率。
from PIL import Image
def produceImage(file_in, width, height, file_out):
image = Image.open(file_in)
resized_image = image.resize((height, width), Image.ANTIALIAS)
resized_image.save(file_out)
if __name__ == '__main__':
file_in = '1.jpg'
width = 500
height = 500
file_out = '11.jpg'
produceImage(file_in, width, height, file_out)