Python PIL 图像打开和保存更改图像文件大小?

Python PIL image open and save changes image file size?

我用PIL打开和保存同一张jpg图片,但是尺寸明显变小了。有人可以解释一下幕后发生的事情吗?

我运行

a = Image.open('a.jpg')
a.save('b.jpg')

a.jpg 的大小为 5MB,而 b.jpg 只有 600KB。我把它们放大并并排比较,基本上看不出画质有什么不同。有人可以解释一下吗?

非常感谢!

Pillow 中 jpg 的默认保存质量是 75。我敢打赌你的原始图像是以更高质量设置保存的。

The image quality, on a scale from 1 (worst) to 95 (best). The default is 75. Values above 95 should be avoided; 100 disables portions of the JPEG compression algorithm, and results in large files with hardly any gain in image quality.

http://pillow.readthedocs.io/en/3.2.x/handbook/image-file-formats.html#jpeg