我的 .jpg 文件比 .png 大?

Syl*_*a20 6 png jpeg image image-compression

我使用 Microsoft Paint 创建了一张 15248 x 6552 的纯色图片。我将它保存为 .png 和 .jpg 并希望 .jpg 小于 .png,但事实并非如此。.jpg 文件为 1.49MB,而 .png 为 391KB。jpeg 作为有损压缩在技术上不应该更小吗?

我在某处读到 .png 更适合纯色等,所以我从网上下载了一张图片(不是纯色)并使用油漆将它保存为两种格式。这次 jpeg 比 png 小。仅仅是因为颜色的渐变吗?如果是,那为什么?

即使图片是纯色的,jpg encodng 是否应该能够更好地压缩它?

leo*_*loy 7

It's to be expected that PNG performs better than JPEG in this scenario.

As pointed out in other answer, PNG does a per-line pixel prediction, followed by ZLIB compression. If the image has has a single colour, the prediction will produce a constant zero value for all the pixels, except for the start of each row. Hence the compression will be very effective. I'd bet that if the image were "landscape" (6552 x 15248 instead of 15248 x 6552) the compression would be even a little better.

相反,JPEG 压缩将图像划分为 8x8 像素的块,并且对于每个像素,它尝试对低频分量进行精细量化,对高频分量进行粗略量化。这对于“自然”(摄影或渲染)图像非常有效,但对于颜色很少(或单一颜色!)的图像则不是很好。

请参阅此处的一些比较