import Image
def change_resolution(picPath, reslution):
img = Image.open(picPath)
x, y = img.size
print x,y
changex = float(x)/reslution[0]
changey = float(y)/reslution[1]
if changex > 1 or changey >1:
change = changex if changex > changey else changey
final_fenbianlv = (int(x / change), int(y / change))
print final_fenbianlv
img.resize(final_fenbianlv).save('result.jpg')
if __name__ == '__main__':
change_resolution('pictest.jpg',(1136, 640))
修改照片分辨率,宽高的比例不变
最新推荐文章于 2022-09-13 17:32:54 发布