最近学校让上传照片,对照片尺寸要求比较多,学校给的照片调整程序又用不了,所以自己三行写了一个 ,,,
from PIL import Image
def adj(ori_path, save_path, weight, height, w_dpi, h_dpi):
# ori_path, save_path 原始照片路径,保存路径
# weight, heigh 宽,高像素
# w_dpi, h_dpi 水平、垂直分辨率
image = Image.open(ori_path)
resized_image = image.resize((weight, height), Image.ANTIALIAS)
resized_image.save(save_path, dpi=(w_dpi, h_dpi))
if __name__ == "__main__":
adj('1.jpg', '1_adj.jpg', 358, 441, 350.0, 350.0)