Git Product home page Git Product logo

optimize-png-mbtiles's Introduction

optimize-png-mbtiles

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. While 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:

original optimized
127KB
31KB
131KB
31KB
128KB
33KB
137KB
32KB

On my laptop optimizing basemapat_standard16.MBTiles takes about:

  • ~30 minutes for tile optimization
  • ~3 minutes for final database vacuum

Usage

Note:

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.

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

optimize-png-mbtiles's People

Contributors

wilhelmberg avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.