TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Finally Understanding PNG (2017)

125 点作者 Asdrubalini大约 4 年前

13 条评论

masklinn大约 4 年前
&gt; This is due to the fact that the specification of the PNG has a sliding window of 32 kB for performance reasons.<p>It’s a bit of a shortcut: in reality PNG uses DEFLATE, and it’s DEFLATE which has a 32kB window.<p>And it’s not exactly performance reasons but memory budget, especially as deflate was designed for <i>streaming</i>, both when compressing and decompressing: when decompressing you need a buffer at least as large as the window, and when compressing you need that plus most likely an index of some sort (so you don’t have to look for matches linearly through the buffer).<p>This is more relevant with the context that Phil Katz created deflate in 1991, high-end desktops reached high single-digit megabytes of RAM but the low end might not even be there (Windows 3.0 required 1MB to run decently).<p>By comparison, if memory serves zstd uses a window of 8MB (or 16 depending on setting), though configurable anywhere from 1k to 512MB
评论 #27290376 未加载
评论 #27291348 未加载
acqq大约 4 年前
I&#x27;m old enough to find that it must be noted: &quot;HDD&quot; was <i>never</i> used for diskettes, even the &quot;high density&quot; ones.<p>HDD:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Hard_disk_drive" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Hard_disk_drive</a><p>Diskettes:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Floppy_disk#3+1%E2%81%842-inch_disk" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Floppy_disk#3+1%E2%81%842-inch...</a><p>I&#x27;m commenting &quot;HDD&quot; as written in: &quot;1.44 MB. This is also pretty much the size of an uncompressed BMP image (and incidentally the size of a 3.5 &quot; HDD ... for all who can still remember&quot; in the current text of the article.
评论 #27294333 未加载
评论 #27289511 未加载
nayuki大约 4 年前
This article talks about understanding the PNG pixel data and compression, which is wonderful. Recently I made a tool to understand another aspect of the PNG file format, which is the full list of chunks, metadata chunks, and chunk fields. <a href="https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;png-file-chunk-inspector" rel="nofollow">https:&#x2F;&#x2F;www.nayuki.io&#x2F;page&#x2F;png-file-chunk-inspector</a>
Hamuko大约 4 年前
Fun PNG fact: the official pronunciation of &quot;PNG&quot; is actually &quot;ping&quot;: <a href="http:&#x2F;&#x2F;www.libpng.org&#x2F;pub&#x2F;png&#x2F;spec&#x2F;iso&#x2F;index-object.html#1Scope" rel="nofollow">http:&#x2F;&#x2F;www.libpng.org&#x2F;pub&#x2F;png&#x2F;spec&#x2F;iso&#x2F;index-object.html#1Sc...</a><p>I imagine there won&#x27;t be a mainstream culture war over it like there is with GIF and JIF though.
sprash大约 4 年前
As additional strategy for reducing PNG sizes losslessly not mentioned in the article is the brute force optimization of the DEFLATE compression algorithm (via zopflipng). This gives you usually a few percent improvement for &quot;free&quot;.
blowski大约 4 年前
I learned a lot from that, thank you.<p>I wonder how much bandwidth I&#x27;ve wasted for people over the years because I&#x27;ve saved poorly optimised versions from Photoshop. Are there automated tools that can be included in a CI pipeline to help with this?
评论 #27293600 未加载
评论 #27290906 未加载
评论 #27288837 未加载
评论 #27291375 未加载
评论 #27288786 未加载
TonyTrapp大约 4 年前
&gt; These filters are the reason why the PNG is a nose ahead of the GIF format and is therefore almost always smaller<p>Not really. I found that for many many many pictures, not using a filter turns out to be the smallest option. It&#x27;s really just that DEFLATE is much better than LZW as used by GIF.
UglyToad大约 4 年前
At some point I&#x27;m going to get round to adding heuristic filter selection to my PNG library BigGustave [0]. I have a TODO note for how to start implementing it.<p>Though to be honest using Palette for colors tends to produce a huge saving for a lot of image types (those with 256 or fewer colors, so documents, not natural scenes) making filter selection a small added bonus.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;EliotJones&#x2F;BigGustave&#x2F;blob&#x2F;master&#x2F;src&#x2F;BigGustave&#x2F;PngBuilder.cs#L504" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;EliotJones&#x2F;BigGustave&#x2F;blob&#x2F;master&#x2F;src&#x2F;Big...</a>
ericpauley大约 4 年前
Nit: it was somewhat disingenuous that the first two images aren&#x27;t actually encoding the same results, since noise was added to the right image to accentuate the paletting effects. If the image on the right didn&#x27;t have noise the effect would be far less pronounced.
userbinator大约 4 年前
<i>Finding the optimal filter for each line is a science in itself, which, of course, could be approached with brute computer power. But since you probably do not want to wait a week in front of your computer, until the PNG is finally calculated, the filters are selected by experience values and assumptions.</i><p>That paragraph makes it sound like this article was written two decades ago. pngcrush, which does bruteforce, still takes only a minute or two on average (less than screen-sized) files.
评论 #27290634 未加载
评论 #27290537 未加载
huachimingo大约 4 年前
Pico-8 has its cartridge format on a custom PNG.
the2ndfloorguy大约 4 年前
Wonderful article.
drsopp大约 4 年前
&gt; A PNG is compressed in three steps: pre-filtering, dictionary-based coding via LZ77, and finally entropy coding according to a certain Mr. Huffman.<p>Huffman was a Doctor of Science.<p>Also, (2017).<p>Edit: Couldn&#x27;t OP&#x27;s email. I don&#x27;t have Twitter.