mapslice
Slices a given image into tiles to be used for a interactive map display. (including command-line tool)
Last updated 3 months ago by leichtgewicht .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mapslice 
SYNC missed versions from official npm registry.

mapslice - Image crop & slice tool

Build Status js-standard-style

mapslice is a tool to cut images into slices of various zoom levels for use in interactive maps.

Javascript tools for high-performant viewing of huge images are plenty available, yet cropping and slicing images can be a pain with the given tools. mapslice automatically detects which tile-sizes your input-material supports and creates all possible tiles to be used by a common javascript map tool like polymaps, kartograph or PanoJS.

Installation

via npm:

$ npm install mapslice

Command line

After installing the latest node, you can use mapslice as a command-line tool by installing it with:

$ npm install mapslice -g

Also make sure that you have GraphicsMagick or ImageMagick installed and available in your command-line!

Once the prerequisites are given, run mapslice using:

$ mapslice -f test.jpg

For more documentation run mapslice without arguments:

$ mapslice

Script usage

const MapSlicer = require('mapslice')

// The parameters passed here are equal to the command-line parameters
const mapSlicer = new MapSlicer({
  file: `myImage.jpg`,               // (required) Huge image to slice
  output: `myImage/{z}/{y}/{x}.png`, // (default: derived from file path) Output file pattern
  outputFolder: './output',          // (default: derived from file path) Output to be used for. Use either output or outputFolder, not both!
  tileSize: 512,                     // (default: 256) Tile-size to be used
  imageMagick: true,                 // (default: false) If (true) then use ImageMagick instead of GraphicsMagick
  background: '#00000000',           // (default: '#FFFFFFFF') Background color to be used for the tiles. More: http://ow.ly/rsluD
  tmp: './temp',                     // (default: '.tmp') Temporary directory to be used to store helper files
  parallelLimit: 3,                  // (default: 5) Maximum parallel tasks to be run at the same time (warning: processes can consume a lot of memory!)
  minWidth: 200,                     // See explanation about Size detection below
  skipEmptyTiles: true,              // Skips all the empty tiles
  bitdepth: 8,                       // (optional) See http://aheckmann.github.io/gm/docs.html#dither
  dither: true,                      // (optional) See http://aheckmann.github.io/gm/docs.html#bitdepth
  colors: 128,                       // (optional) See http://aheckmann.github.io/gm/docs.html#colors
  gm: require('gm'),                 // (optional) Alternative way to specify the GraphicsMagic library
  signal: new (require('abort-controller'))().signal // (optional) Signal to abort the map slicing process
})

mapSlicer.on('start', (files, options) => console.info(`Starting to process ${files} files.`))
mapSlicer.on('imageSize', (width, height) => console.info(`Image size: ${width}x${height}`))
mapSlicer.on('levels', (levels) => { console.info(`Level Data: ${levels}`) }) // see TypeScript declaration for more details
mapSlicer.on('warning', err => console.warn(err))
mapSlicer.on('progress', (progress, total, current, path)  => console.info(`Progress: ${Math.round(progress*100)}%`))
mapSlicer.on('end', () => console.info('Finished processing slices.') )
mapSlicer.start().catch(err => console.error(err))

## Size detection and scaling

To render the image in its fullest glory, mapslice assumes that you want to preserve the original image-quality and chooses input-size as its starting point from which the quality should be reduced. However: If you have a fixed-size map-user-interface then you might want the smallest image quality to fit this user-interface-design in order to assure that its is beautifully visible. To produce tiles that fit this needs you can use the "minWidth" or "minHeight" property which fits the map to have its lowest size matching exactly your required size:

```console
$ mapslice -f test.jpg -w=1000

Will fit the smallest size to be exactly 1000 pixels wide and zoom up from there.

Note

To speed up performance mapslice stores a prescaled version of the each zoom-level in a temorary folder and then just crops off of that. These temporary files can become quite big as they are stored with low compression and high quality in sgi files.

License

MIT

Current Tags

  • 3.0.0                                ...           latest (3 months ago)

19 Versions

  • 3.0.0                                ...           3 months ago
  • 2.0.4                                ...           5 months ago
  • 2.0.3                                ...           5 months ago
  • 2.0.2                                ...           5 months ago
  • 2.0.1                                ...           8 months ago
  • 2.0.0                                ...           2 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.5                                ...           7 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (3)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |