<p>PNG format is lossless format where for compression the image is first "filtered" and this filtered image is then passed to <a href="https://en.wikipedia.org/wiki/DEFLATE" rel="nofollow">DEFLATE</a> 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.</p>

<p>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.</p>

CC BY-SA 3.0
2016-10-12T12:58:21.843Z
2016-10-12T12:58:21.843Z
JarkkoL
<p>How to create PNG files optimized for being compression-friendly? I.e. would it help if image is created (mostly) from 8x8 unicolor blocks?</p>

CC BY-SA 3.0
2016-10-12T10:33:13.833Z
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.
Dan Hulme
CC BY-SA 3.0
2016-10-12T10:50:36.910Z
@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.
tomash
CC BY-SA 3.0
2016-10-12T10:52:19.673Z
PNG is not stored in blocks, so no that is useful but not optimal
joojaa
<image-processing><image><compression><artifacts>
Compression-friendly PNG files
tomash
# Compression-friendly PNG files

(Asked by: username_0 on 2016-10-12)

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

**Tags:** image-processing, image, compression, artifacts

> **Comments:**
> **username_1**: 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.  
> **username_0**: @username_1 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.  
> **username_2**: PNG is not stored in blocks, so no that is useful but not optimal  

---

## 1 answers

### Answer by username_3 on 2016-10-12. Score: 2

PNG format is lossless format where for compression the image is first "filtered" and this filtered image is then passed to [DEFLATE](https://en.wikipedia.org/wiki/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.


---

