GithubHelp home page GithubHelp logo

nvdnkpr / mapslice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from martinheidegger/mapslice

0.0 2.0 0.0 176 KB

Slices a given image into tiles to be used for a interactive map display. (including command-line tool)

mapslice's Introduction

mapslice - Image crop & slice tool

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

var mapslice = require("mapslice");

// The parameters passed here are equal to the command-line parameters
var mapSlicer = mapslice({
    file: "myImage.jpg",               // (required) Huge image to slice
    output: "myImage/{z}/{y}/{x}.png", // Output file pattern
    tileSize: 512,                     // (default: 256) Tile-size to be used
    imageMagick: true,                 // (default: false) If (true) then use ImageMagick instead of GraphicsMagick
    background: "#0000000",            // (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
});

mapSlicer.on("start", function(files, options) {
    console.info("Starting to process "+files+" files.");
});

mapSlicer.on("error", function(err) {
    console.error(err);
});

mapSlicer.on("progress", function(progress, total, current, file) {
    console.info("Progress: "+Math.round(progress*100)+"%");
});

mapSlicer.on("end", function() {
    console.info("Finished processing slices.");
});

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:

$ mapslice -f test.jpg -w=1000

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

Image formats

mapslice relies on gd for image processing. gd detect the file format for reading and writing using the passed-in file extension.

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

mapslice's People

Contributors

martinheidegger avatar

Watchers

Navid Nikpour 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.