未知名网友让我给他的图片从98k改为20k以下,本想找个app搞定的,结果要收费,一怒之下找资料写代码。。。。。。Python,无所不能
import PIL.Image as Image
infile = 'images/001.jpg'
outfile = 'images/002.jpg'
im = Image.open(infile)
(x, y) = im.size # read image size
x_s = 250 # define standard width
y_s = int(y * x_s / x) # calc height based on standard width
out = im.resize((x_s, y_s), Image.ANTIALIAS) # resize image with high-quality
out.save(outfile)
print('original size: ', x, y)
print('adjust size: ', x_s, y_s)
别的也没啥说的
ok,那就这样吧~
欢迎各位大佬留言吐槽,也可以深入交流~