Sprite generator that takes a root directory and recursively combines all images into a sprite and style sheet.
Spritegen requires a fork of node-canvas, which requires Cairo. To install Cairo follow the portion of the Wiki that pertains to your operating system. Only follow the installing Cairo section, I'll walk you through the rest. Once Cairo is installed follow these steps:
npm install spritegen
If you're noticing that we are requiring a module called canvas-gyp instead of canvas, it's because node-canvas includes both waf and gyp. It is buggy and in our experience, always fails to compile on Windows machines. We created a fork called canvas-gyp that only uses gyp, which installs correctly on Windows. ## Examples
$ spritegen --dir site/images
Recursively combines all images inside the directory "site/images" into one sprite.png and sprite.css per directory and sub-directory.
site/ images/ icons/ answer.png connect.png discover.png
The sprite.css is generated with classes by folder and file name.
This CSS works by simply assigning the class name to an element.
spritegen can also be called directly by including the module.
var SpriteGen = ;var imagesPath = path;var spriteGen = dir: imagesPath padding: 5 ;spriteGen;
$ spritegen --help => [spritegen] Sprite generator that takes a root directory and recursively combines all images into a sprite and style sheet. * Version: 0.0.1 * Usage: spritegen [options] Options: --help Shows help. --dir Root directory to recursively process. --padding Padding between images in pixels. --verbose Sets if logging is verbose (true/false).