Shrink your PNG files with PNGCRUSH

You can reduce the size of the PNG files you import into the Nextion by using a program called PNGCRUSH. This program shrinks the size of PNG files via two methods. First, it can remove optional meta data from the file. Second, it can try 113 different compression methods and select the smallest one.

The web page for the program is pngcrush at sourceforge

However, at least for Windows, I would recommend installing the Gnu Win PngUtils . The installer from the pngcrush webpage for Windows was incomprehensible, but with the Gnu Win PngUtils it is straightforward.

You can see what options are available by typing in the command line:

pngcrush --help

Here is is the command line I use:

pngcrush -d …\crushed -brute -fix -force -l 9 -rem gAMA -rem cHRM -rem iCCP -rem sRGB -rem alla -rem text -rem time *.png

Even with the -brute option (try all 111 compression algorithms, it runs very fast). Without the -brute option, the program will use heuristic methods to try a few algorithms it thinks will work best – this works pretty well.

For example, I had one directory of 123 images, total size 1.04 MB. After crushing without -brute, the size reduced to 848 KB. After crushing with -brute, it was further reduced to 448 KB.

In another example, I had a directory of 114 images, total size 23.7 MB. After crushing (with -brute), the size reduced to 21.7 MB.

Have you tested the resulting TFT size before and after?

Since the Nextion firmware inflates imported picture resources to an internal bitmap format for quicker displaying (without having to decompress these at runtime), shrinking resources before you import them has most probably no effect on the compiled .tft file size, at least on the T and K Series. I haven‘t yet looked closer to this on the P series, there it might be that the enhanced media capabilities of the CPU could be helpful. But for what? They have plenty of memory…

1 Like

Exactly what i think. Every full 480x320 page on my 3.5" display takes 300k no matter what.