Walks through all tiles in an mbtiles file (only raster PNG mbtiles supported) and optimizes them (in place!) using pngquant.
optimize-png-mbtiles has been developed for and tested with
basemap.at Verwaltungskarte Raster Offline Österreich (bmap_standard_mbtiles_L00bisL16.zip).
If it works with other mbtiles files is a game of luck and depends on their internal database schema and how they were created.
basemapat_standard16.MBTiles adheres to the mbtiles spec from a read-only point of view, its internal database schema is different from the schema of mbtiles created with tools from the Mapbox universe (eg node-mbtiles).
No analysis of the actual database schema is performed and
optimize-png-mbtiles most likely will not work with mbtiles created with Mapbox tools.
basemapat_standard16.MBTiles weighs in at +16GB which essentially makes it useless for its intended offline use (think mobile apps or shared hosting).
Maximum compression reduces those +16GB to ~4.6GB, still a lot, but much better to handle.
Maximum compression is of course noticeable in a side by side comparision, but not that bad either:
On my laptop optimizing
basemapat_standard16.MBTiles takes about:
- ~30 minutes for tile optimization
- ~3 minutes for final database vacuum
Make sure there's enough free RAM before starting the tool. At least 5GB (7GB recommended, the more the better). The final database vacuum needs a lot of it.
basemap.at Verwaltungskarte Raster Offline Österreich
Releasestab (sorry, Windows only)
optimizepngmbtiles.exe -f basemapat_standard16.MBTiles
Default settings are optimized for size, sacrificing some quality on the way.
Adjust settings to get desired output quality. Even moderate compression without visible degradation will save a few GBs already.
λ optimizepngmbtiles.exe -f, --mbtiles=VALUE Path to MBTiles -m, --min-quality=VALUE PNG min quality [0..100]. Default:0 -x, --max-quality=VALUE PNG max quality [0..100]. Default:20 -s, --speed=VALUE PNG speed [1..10]. Slower better quality. Default:1 -t, --threads=VALUE Threads. Default (Processors):8 -b, --batch-size=VALUE Batch size. Number of tiles processed in one batch. Default:1000