4 ms·
> both .png and .jpg are already compressed formats, with "better than gzip" strength FWIW, PNG and gzip both use the DEFLATE algorithm, so I wouldn't call PNG
by dnet 9y ago
> both .png and .jpg are already compressed formats, with "better than gzip" strength
FWIW, PNG and gzip both use the DEFLATE algorithm, so I wouldn't call PNG's compression "better than gzip".
Source: https://en.wikipedia.org/wiki/DEFLATE https://en.wikipedia.org/wiki/DEFLATE
> This has led to its widespread use, for example in gzip compressed files, PNG image files and the ZIP file format for which Katz originally designed it.
- BeeOnRope 9y agoLike any domain-specific algorithms PNG uses deflate as a final step after using image-specific filters which take advantage of typical 2D features. So in general png will do much better than gzip on image data, but it will generally always do at least as well (perhaps I should have said that originally). In particular, the worse case .png compression (e.g., if you pass it random data, or text or something) is to use the "no op" filter followed by the usual deflate compression, which will end up right around plain gzip. Now at least as good is enough for my point: by compressing a .png file with gzip you aren't going to see additional compression in general. When compressing a base-64 or hex encoding .png file, the additional compression you see is largely only a result of removing the redundancy of the encoding, not any compression of the underlying image.
- BeeOnRope 9y agoOoops, that should read "Like many domain-specific algorithms" not "Like any ..."