Have ideas to improve npm?Join in the discussion! »


    2.0.3 • Public • Published


    Create zoom tile pyramids from a large image. There are other packages very similar to this one, but none did exactly what I needed, so I made mine.


    You need imagemagick installed. In ubuntu, you can install it like this:

    sudo apt-get update
    sudo apt-get install imagemagick


    npm install image-tiler --save


    Include it like this:

    var tile = require('image-tiler').tile;

    For example:

    var tile = require('image-tiler').tile;
    var tilePromise = tile('input/image.png', 'output/folder/', 'save_pattern_{z}/tile_{x}_{z}.png');
    tilePromise.then(() => console.log('Finished.'))
    .catch((error) => console.log('Error', error));
    // Output tiles will look like: output/folder/save_pattern_0/tile_0_0.png etc.


    The tile function accepts the following parameters:

    tile(inPath, outPath, pattern, [options]);

    inPath is the path and filename of the large image you want to slice. The format will be deduced from the filename, and it accepts any format that ImageMagick accepts. .jpeg, .png, etc.

    outPath is a path to a directory where the output tiles will be saved.

    pattern describes the structure and file names of the tile files. {z}, {x}, {y} will be replaced with the file's values. The extension of the pattern will determine the image format. Supported formats are any supported by ImageMagick. .jpeg, .png, etc. You can have directories or not, but only for the zoom level. E.g. zoom-{z}/tile-{y}_{x}.png is OK, but {z}/{x}/{y}.png is not.

    options is an optional object with the following optional properties:

    options.tmpDir a path to the directory where tile will write intermediate files. Defaults to process.env.TMPDIR (usually /tmp) or /tmp

    options.tileSize defaults to 256

    options.quality defaults to 100

    options.invertZoom false by default. If true, zoom levels will go from 0 (original image scale) to N (one tile, all zoomed out). Which is the opposite of the default behavior.


    npm i image-tiler

    DownloadsWeekly Downloads






    Unpacked Size

    7.65 kB

    Total Files


    Last publish


    • avatar