npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ssa-smith

v0.1.0

Published

Utility to build a sprite from a collection of images, forked from Todd Wolfson's spritesmith

Readme

Spritesmith

Utility that takes image files and generates spritesheets and coordinate maps.

Once you have satisfied the requirements, spritesmith can be installed via npm install spritesmith.

Spritesmith is also available as a grunt plugin.

Requirements

Spritesmith supports multiple sprite engines however all of the current engines require external software to be installed.

As a result, you must either have Cairo or Graphics Magick installed for Spritesmith to run properly.

Cairo (node-canvas)

Due to dependance on node-canvas, you must install Cairo.

Instructions on how to do this are provided in the node-canvas wiki.

Additionally, you will need to install node-gyp

sudo npm install -g node-gyp

Graphics Magick (gm)

The alternative engine is gm which runs on top of Graphics Magick.

I have found it is best to install from the site rather than through a package manager (e.g. apt-get) to get the latest as well as without transparency issues.

Documentation

Spritesmith is a standalone function

/**
 * Spritesmith generation function
 * @param {Object} params Parameters for spritesmith
 * @param {String[]} [params.src] Images to generate into sprite sheet
 * @param {String} [params.engine="auto"] Engine to use (canvas, gm, or user-defined via Spritesmith.addEngine)
 * @param {String} [params.algorithm="top-down"] Algorithm to pack images with (top-down or user-defined via Spritesmith.addAlgorithm)
 * @param {Mixed} [params.exportOpts] Options to pass through to engine for export
 * @param {Function} callback Function that receives compiled spritesheet and map
 * @returns {Mixed} callback[0] err If an error was encountered, this will be returned to callback
 * @returns {Object} callback[1] result Result object of spritesmith
 * @returns {String} callback[1].image Binary string representation of image
 * @returns {Object} callback[1].coordinates Map from file name to an object containing x, y, height, and width information about the source image
 */

Canvas export options

For the canvas engine, the current output options are:

{
  'format': 'png' // Format to export the canvas to (png or jpeg)
}

gm export options

For the gm engine, the current output options are:

{
  'format': 'png', // Format to export the canvas to (png or jpeg)
  'quality': 75 // Quality of the output image
}

Available packing algorithms

The available packing algorithms are: top-down, left-right, diagonal (\ format), alt-diagonal (/ format).

Adding new engines

Example engines can be found in src/engines.

New engines can be added via Spritesmith.addEngine(name, engine);.

If you decide to build a new engine, there are some utilities in src/utils which may be helpful.

Adding new packing algorithms

Algorithms are maintained inside of twolfson/layout. Example algorithms can be found in twolfson/layout/lib/algorithms.

New algorithms can be added via Spritesmith.Layout.addAlgorithm(name, algorithm);.

Examples

var sprites = ['sprite1.png', 'sprite2.jpg', 'sprite3.png'];
spritesmith({'src': sprites}, function (err, result) {
  result.image; // Binary string representation of image
  result.coordinates; // Object mapping filename to {x, y, width, height} of image
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.

License

Copyright (c) 2012 Ensighten Licensed under the MIT license.