Skip to content

iursevla/TileCompressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MultiThread lossy Tile Compressor

This is a simple nodejs executable that allows the lossy convertion of map tiles generated by Maperative or similar tool using one or more CPU cores (up to the maximum number of cores your processor has).

It uses pngquant to make the compression of the png tile files and by doing this you can save space. Your offline maps will take less disk space and will be faster to load.

You can pass arguments to pngqaunt in the command line or by editing the worker.js pngquantOptions variable.

Usage

node compress.js --cpus 4 input output --options --speed 1 --strip --quality=60-80
  • --cpus - should be followed by the number of cpu cores to use to compress the png tiles. Each core will be assigned n/number tiles for compression. If you don't supply this number, the maximum cores available on your CPU will be used. [Optional parameter]

  • input - Name of the input folder where you PNG tiles are located. [Required parameter]

  • output - Name of the output folder where the compressed PNG tiles will be located. [Required parameter]

  • --options - should be followed by the options you want to pass to pngquant. [Optional parameter]

Performance

  • Tested with Intel Core-i5 4690K 3.5GHz 4 core processor.
  • All tests with pngquant options: --speed 1 --strip --quality=60-80 ./input/[name].png -o ./output/[name].png,

Test 1 (MTS)

  • 4 zoom levels(13-16)
  • 351 Tiles
  • Before compression size = 6 290 120 bytes (~ 5.99 MB)
  • After compression size = 1 973 343 bytes (~ 1.88MB)

Using 1 Core Execution Time was 112s = 1min52s

Using 4 Cores Execution Time was 42s

Test 2 (MTS Pro)

  • 5 zoom levels(13-17)
  • 1219 Tiles
  • Before compression size = 15 058 480 bytes (~ 14.3 MB)
  • After compression size = 4 614 525 bytes (~ 4.40 MB)

Using 1 Core Execution Time was 387s = 6min27s

Using 4 Cores Execution Time was 134s = 2min14s

Test 3 (Mine)

  • 6 zoom levels(13-18)
  • 10192 Tiles
  • Before compression size = 127 632 671 bytes (~ 121MB)
  • After compression size = 31 287 741 bytes (~ 29.8MB)

Using 1 Core Execution Time was 3752s = 62m32s

Using 4 Cores Execution Time was 1381s = 23m01s

Summary

Tests Number Tiles Size (MB) Size (MB) Exec. Time 1 Core Exec. Time 4 Cores
1 351 5.99 1.88 112s(1min52s) 42s
2 1219 14.3 4.40 387s(6min27s) 134s(2min14s)
3 10192 121 29.8 3752s(62m32s) 1381s(23m01s)

Dependencies

  1. shelljs - Portable Unix shell commands for Node.js. To install use: npm install -g shelljs