png格式是无损的,因为它有一个压缩参数?

PNG格式应该是无损格式,但是当您将图像保存为PNG文件时,会要求您选择压缩级别。这是否意味着PNG格式实际上并不是无损的?今天的超级用户问答有助于澄清好奇读者的困惑。...

png格式是无损的,因为它有一个压缩参数?

PNG格式应该是无损格式,但是当您将图像保存为PNG文件时,会要求您选择压缩级别。这是否意味着PNG格式实际上并不是无损的?今天的超级用户问答有助于澄清好奇读者的困惑。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者pkout想知道PNG图像的质量是否受所选压缩级别的影响:

As I understand it, PNG files use lossless compression. However, when I am using an image editor such as Gimp and try to save an image as a PNG file, it asks for a compression level ranging between 0 and 9.

If it has a compression parameter that affects the visual precision of the compressed image, how is PNG lossless then? Can someone please explain this to me? Do I get lossless behavior only when I set the compression level to 9?

根据您选择的压缩级别,图像质量是否有差异?

答案

超级用户贡献者LordNeckbeard和jjlin为我们提供了答案。首先,领主:

PNG is Compressed, but Lossless

The compression level is a trade-off between file size and encoding/decoding speed. To overly generalize, even non-image formats such as FLAC have similar concepts.

Different Compression Levels, Same Decoded Output

Although the file sizes are different due the the different compression levels, the actual decoded output will be identical. You can compare the MD5 hashes of the decoded outputs with ffmpeg using the MD5 muxer. This is best shown with some examples.

Create PNG Files

007Ys3FFgy1gpfa02i1nmj30hd01ndft

  • By default, ffmpeg will use -compression_level 100 for PNG output.
  • A quick, sloppy test showed that 100 (the highest compression level) took roughly three times longer to encode and five times longer to decode than 0 (the lowest compression level) in this example.

Compare File Size

007Ys3FFgy1gpfa02ywvrj30hd029q2s

Decode the PNG Files and Show MD5 Hashes

007Ys3FFgy1gpfa03ggvpj30hd03ijrh

Since both hashes are the same, you can be assured that the decoded outputs (the uncompressed raw files) are exactly the same.

接着是jjlin的回答:

PNG is lossless. GIMP is most likely not using the best choice of wording in this case.

Think of it as quality of compression or level of compression. With lower compression, you get a bigger file, but it takes less time to produce, whereas with higher compression, you get a **aller file that takes longer to produce.

Typically you get diminishing returns, i.e. not as much decrease in size compared to the increase in time it takes when going up to the highest compression levels, but it is up to you.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-11 03:50
  • 阅读 ( 248 )
  • 分类:互联网

你可能感兴趣的文章

知道何时使用哪种文件格式:png与jpg、doc与pdf、mp3与flac

...几个字母?这些是文件扩展名,用于定义文件另存为哪种格式。一种类型的文件很少有单一的格式,因此您可能会对它们的不同之处以及最好使用哪种格式感到困惑。 ...

  • 发布于 2021-03-14 05:40
  • 阅读 ( 398 )

介绍了如何在photoshop中保存高质量的图像

...?事实证明,这不是那么直观。Photoshop允许使用多种文件格式和参数,每种格式和参数都有各自的优点。有时,以特定文件格式保存图像可能会降低工作质量。以下是一个指南,可以确保您以尽可能高的质量保存图像。 ...

  • 发布于 2021-03-17 01:54
  • 阅读 ( 205 )

文件压缩是如何工作的?

...不必要的信息位来减小文件大小。它在图像、视频和音频格式中最为常见,在这些格式中,源媒体的完美表示是不必要的。这类媒体的许多常见格式都使用有损压缩;MP3和JPEG是两个流行的例子。 ...

  • 发布于 2021-03-20 02:33
  • 阅读 ( 222 )

jpg与jpeg:这些图像文件格式之间有什么区别?

并非所有的图像文件格式都是相同的。事实上,它们中的许多都是为了解决现有格式无法解决的问题而创建的。例如,JPEG的出现是因为图像文件的大小占用了太多的存储空间。 ...

  • 发布于 2021-03-26 15:54
  • 阅读 ( 320 )

什么是webp文件(如何打开文件)?

带有.webp文件扩展名的文件是由Google开发的一种文件格式,它可以在不牺牲存储空间质量的情况下减小图像的大小。WebP图片的设计目的是让网络更快,有更小、更丰富的照片供开发者使用。 相关:什么是文件扩展名? 什么是w...

  • 发布于 2021-04-03 11:13
  • 阅读 ( 126 )

如何将图像转换为png格式

...背景上保持其原始外观。我们将介绍几种将图像转换为PNG格式的方法。 什么是png文件(a png file)? PNG,或便携式网络图形,是一种流行的图像格式,用于互联网图形的能力,以支持浏览器的透明度。它最早是在20世纪90年代作为GIF...

  • 发布于 2021-04-03 20:21
  • 阅读 ( 156 )

什么是无损文件格式&为什么不应该将有损转换为无损

无论你处理的是图像、音乐还是视频文件,了解不同格式之间的差异以及何时使用它们都是很重要的。使用错误的格式可能会破坏文件的质量或使其文件大小过大。 有些类型的媒体文件格式是“有损”的,有些类型是“无损的...

  • 发布于 2021-04-10 04:07
  • 阅读 ( 182 )

有损(the lossy)和无损压缩(lossless compression)的区别

...旦photoshop编辑完成,图像将以高质量转换为JPEG(或类似格式)。然后提交给客户。 哪个最好? 没有“最好的”。这取决于你计划如何处理你的文件以及你有多少可用的存储空间。 除非你看重高质量,否则无损是最好的。 我有...

  • 发布于 2021-06-24 23:28
  • 阅读 ( 363 )

有损(lossy)和无损压缩(lossless compression)的区别

...re 2: Photo saved using Lossless Compression 无损数据压缩在ZIP文件格式和GNU工具gzip中使用。某些图像文件格式(如PNG或GIF)仅使用无损压缩。它也用于文本和数据文件。无损音频格式用于存档或**目的。 有损(lossy)和无损压缩(lossless compre...

  • 发布于 2021-06-30 22:54
  • 阅读 ( 955 )

gif格式(gif)和jpeg格式(jpeg)的区别

GIF和JPEG是互联网上最流行的两种图形文件格式。建议将JPEG用于照片,GIF用于动画,PNG用于在线使用所需的其他图像。对比图 window.getratingjs=真; gif与jpeg对比图 gif格式jpeg...

  • 发布于 2021-07-04 08:50
  • 阅读 ( 256 )
蒯人八顽炒tor
蒯人八顽炒tor

0 篇文章

相关推荐