from PIL import Image
import os
im = Image.open('./test.png')
# w, h = im.size
# print('Original image size: %sx%s' % (w, h))
# im.thumbnail((w//2, h//2))
# print('Resize image to: %sx%s' % (w//2, h//2))
# 输出转换前的图像大小(单位是字节)
print(os.path.getsize('./test.png'))
rgb_im = im.convert('RGB')
# quality是默认参数,默认是75(此处存疑)
rgb_im.save('test_jpg.jpg', quality=5)
# 输出转换后的图像大小(单位是字节)
print(os.path.getsize('./test_jpg.jpg'))