1.1.6 • Published 11 months ago

sprite-me v1.1.6

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Sprite-me

The spritesheet creation tool for Node.js

SpriteMe designed as core module which do not create or modify any files.

If you want build sprites during build procces look at Sprite-me webpack plugin

Installation

  • Install ImageMagic V7.

    Version 7 is required. Check it by running magick --version

    I recomend to use ImageMagick Easy Instal
    Some package managers like brew can install imagemagick with version 6

  • Install package: npm i -s sprite-me.

Usage

Base usage spriteMe(images: string[], options?: Object).

Returns object with next keys:

  • image - Buffer with generated sprite
  • frames - Frames object
  • meta - Meta information Object

Script example to create and save sprite:

const fs = require('fs');
const spriteMe = require('sprite-me');

const imageName = 'spriteMe.png';
const jsonName = 'spriteMe.json'
const images = ['./img1.png', './img2.png'];

(async () => {
    const { meta, frames, image } = await spriteMe(images);
    
    const json = JSON.stringify({
        meta: {
            ...meta,
            image: imageName,
        },
        frames,
    });

    fs.writeFileSync(imageName, image);
    fs.writeFileSync(jsonName, json);
})();

Options

Options can be passed as second argument

spriteMe(images, { format: 'jpg', gap: 100 })

  • format - Default png - Format of compiled image.
  • gap - Default 10 - Distance beetween images.
1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

12 months ago

1.1.3

12 months ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago