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

2024-10-02 16:29:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我用PIL打开并保存了相同的jpg图像,但是大小明显减小了。有人能解释一下引擎盖下面是怎么回事吗?在

我跑

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

a.jpg的大小为5MB,而b.jpg只有600KB。我把它们放大,并排比较,基本上看不出画面质量的差异。有人能解释一下吗?在

非常感谢!在


Tags: 图像imagepilsave差异openjpg引擎盖
1条回答
网友
1楼 · 发布于 2024-10-02 16:29:35

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

相关问题 更多 >