Python PIL图像打开并保存更改图像文件的大小? [英] Python PIL image open and save changes image file size?

查看:54
本文介绍了Python PIL图像打开并保存更改图像文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PIL打开并保存相同的jpg图像,但是尺寸大大减小了.有人可以解释一下幕后情况吗?

I used PIL to open and save the same jpg image, but the size reduces significantly. Could somebody explained what's going on under the hood?

我跑步

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

a.jpg的大小为5MB,而b.jpg的大小仅为600KB.然后将它们放大并进行比较,基本上看不出图像质量有什么不同.有人可以解释一下吗?

a.jpg has the size 5MB, whereas b.jpg is only 600KB. and I enlarge them and compared side by side and basically see no differences in the picture quality. Could somebody explain this?

非常感谢!

推荐答案

Pillow中jpg的默认保存质量为75.我敢打赌,您的原始图像会以更高的质量设置保存.

The default save quality for jpg in Pillow is 75. I bet your original image is saved with a higher quality setting.

图像质量,等级从1(最差)到95(最佳).默认值是75.应避免大于95的值;100禁用部分JPEG压缩算法,可生成几乎没有任何文件的大文件提高图像质量.

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/zh-CN/3.2.x/handbook/image-file-formats.html#jpeg

这篇关于Python PIL图像打开并保存更改图像文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆