You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement: Investigate control over output PNG IDAT chunk size, might reduce file size of smaller palette-based images #4489
It looks like the input image was optimised using a tool such as pngcrush. Even with compressionLevel set to its highest value I see the following difference:
$ pngchunks input.png | grep IDAT
Chunk: Data Length 11482 (max 2147483647), Type 1413563465 [IDAT]
$ pngchunks output.png | grep IDAT
Chunk: Data Length 8192 (max 2147483647), Type 1413563465 [IDAT]
Chunk: Data Length 4911 (max 2147483647), Type 1413563465 [IDAT]
We previously investigated setting the max IDAT/buffer size in libvips but found the savings were not very useful, however this specific image might be the case that proves otherwise - see libvips/libvips#1357
changed the title [-]PNG output is bigger than PNG input[/-][+]Enhancement: Investigate control over output PNG IDAT chunk size, might reduce file size of smaller palette-based images[/+]on Jan 18, 2026
Activity
[-]PNG compression result is bigger than input[/-][+]PNG output is bigger than PNG input[/+]lovell commentedon Jan 16, 2026
It looks like
input.pngis a palette-based PNG with a meaning-of-lifesque 42 colours:(3 channels * 42 colours = 126 bytes)
You can reduce the number of colours in the palette with
colours, for example:.png({ palette: true effort: 10, + colours: 64, })guoyunhe commentedon Jan 17, 2026
I added
colors: 64and the result:https://github.com/retrobrainz/image-compress-test
lovell commentedon Jan 18, 2026
It looks like the input image was optimised using a tool such as pngcrush. Even with
compressionLevelset to its highest value I see the following difference:We previously investigated setting the max IDAT/buffer size in libvips but found the savings were not very useful, however this specific image might be the case that proves otherwise - see libvips/libvips#1357
guoyunhe commentedon Jan 18, 2026
This image (screenshot) was generated by https://github.com/libretro/retroarch (Hope it is helpful)
lovell commentedon Jan 18, 2026
Thanks, it appears to write a single IDAT chunk (similar to pngcrush).
https://github.com/libretro/RetroArch/blob/bd15d7c02d2614ae878cd2947ba0664269cf2ee0/libretro-common/formats/png/rpng_encode.c#L339-L341
I'll mark this as a future possible enhancement for now.
[-]PNG output is bigger than PNG input[/-][+]Enhancement: Investigate control over output PNG IDAT chunk size, might reduce file size of smaller palette-based images[/+]