1
$\begingroup$

How to create PNG files optimized for being compression-friendly? I.e. would it help if image is created (mostly) from 8x8 unicolor blocks?

$\endgroup$
3
  • $\begingroup$ It depends how much control you have over the image. e.g. making all your images 1 pixel large would have a huge benefit, but that probably isn't useful to you. $\endgroup$ – Dan Hulme Oct 12 '16 at 10:33
  • $\begingroup$ @DanHulme I'm thinking about quality-loss optimization of existing PNG images. The questions is: how to process such images. First idea - pixelize with unicolor blocks. Second idea - decrease palette to have possibly big unicolor shapes. Or maybe something else. I don't know how PNG compression works and what change will result with best effect. $\endgroup$ – tomash Oct 12 '16 at 10:50
  • $\begingroup$ PNG is not stored in blocks, so no that is useful but not optimal $\endgroup$ – joojaa Oct 12 '16 at 10:52
2
$\begingroup$

PNG format is lossless format where for compression the image is first "filtered" and this filtered image is then passed to DEFLATE lossless compression algorithm. The purpose of filtering stage is to make the image more compressible by DEFLATE and current method uses delta-compression from previously decoded pixels.

So if your plan is to pre-process the image in some lossy way, then if you can reduce the deltas so that the following entropy encoding can benefit from it, then you get better compression ratio. For example "blockifying" the image as you suggested would only require more storage for the top-left pixel in the block while the deltas for the remaining pixels would be zero, which DEFLATE can compress very efficiently. This same would apply to any continuous constant color regions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.