With the tiles generated normally the next step would be to serve them, but because I’m planning to distribute them to others, I’m going to the unusual step of optimizing the PNGs. Optimizing PNGs can cut the file size in half, helping downstream users of the tiles I’m generating.
To make use of all the cores of my CPU, I’m going to use find
to locate the PNGs, then the program parallel
to have optipng
operate in parallel.
OptiPNG is a program that performs lossless optimization on PNGs. Because low-zoom tiles are more likely to be viewed and there’s fewer of them, I’ll call the program with different options, doing more aggressive optimizations on low-zoom tiles. There’s no magic right answer for much time to spend compressing, but I found these reasonable, and save up to 50% space on some zooms.
1 2 3 |
|
The space used can be measured with du -hsc --apparent-size osm_tiles/*
. --apparent-size
is essential since many of the tiles will be below the size of one block on disk.
All of this is of course not required, but helps a bit, and is an interesting experiement regardless.