Giter Site home page Giter Site logo

tilescompress's Introduction

tilescompress

PHP script to compress OpenStreetMap tiles. Reduces both total size and count of files.

Since standalone PNG files will be merged to compressed files in a custom format, a PHP file has to be used on the server to provide the original PNG files. This will generate that server-side PHP file, too.

Please be aware that although hosting these compressed files can overcome some limitations of the web hostings (files size and files count), it can trigger another limitations (count of simultaneously running scripts on the server - because you will now run PHP script to retrieve a tile instead of providing PNG file directly).

This is a lossy compression, because it (among other methods) converts the PNG files to 64-color palette.

Compression methods

  • removing parts of PNG files which are always the same (header, IHDR chunk, IEND chunk)
  • removing parts of the PNG files which can be calculated (checksums)
  • converting the PNG files to 64-color palette
  • not storing PNG files with the same contents more than once (a lot of tiles are the same "blue only" or "green only")
  • concatenating more PNG files to one file (to avoid storing filesystem metadata for all the files)

Dependencies

Usage

Compressing:

compress.php <original_directory> <compressed_directory>

Generating server code:

composer install --no-dev
generate_server_code.php <compressed_directory>

Decompressing single file:

decompress.php <compressed_directory> <zoom> <x> <y> <target_fie>

Run test (generates some tiles, compresses them, decompresses, compares):

test.php

Compression results

Zoom Total size before (MiB) Total size after (MiB) Files count before Files count after
0 0.014 0.006 1 1
1 0.039 0.016 4 2
2 0.203 0.072 16 4
3 0.498 0.185 64 8
4 2.8 0.855 256 16
5 10.3 2.8 1024 32
6 28.3 7.9 4096 64
7 84.0 23.5 16384 128
8 270 75.8 65536 256
9 895 240 262144 512
10 2764 697 1048576 1024
11 9523 2151 4194304 2048
12 28774 5632 16777216 4096

tilescompress's People

Contributors

milan11 avatar

Watchers

 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.