canvassmith
node-canvas engine for spritesmith.
Requirements
By default, binaries for macOS, Linux and Windows will be downloaded.
But if you don't have a supported OS or processor architecture the module will be compiled on your system.
This requires several dependencies from node-canvas, you must install Cairo and Pango.
Instructions on how to do this are provided in the node-canvas wiki.
Additionally, you will need to install node-gyp.
npm install -g node-gyp
Getting Started
Install the module with: npm install canvassmith
var Canvassmith = require('canvassmith');
var canvassmith = new Canvassmith();
canvassmith.createImages(['img1.jpg', 'img2.png'], function handleImages (err, imgs) {
if (err) {
throw err;
}
imgs[0].width;
imgs[0].height;
var canvas = canvassmith.createCanvas(200, 300);
canvas.addImage(imgs[0], 0, 0);
canvas.addImage(imgs[1], 50, 100);
var resultStream = canvas['export']({format: 'png'});
resultStream;
});
Documentation
This module was built to the specification for spritesmith engines.
Specification version: 2.0.0
https://github.com/twolfson/spritesmith-engine-spec/tree/2.0.0
engine.createImages(images, cb)
Our createImages
methods supports the following types of images:
- image
String
- Filepath to image - image
Object
- Vinyl object with buffer for image (uses buffer) - image
Object
- Vinyl object with stream for image (uses stream) - image
Object
- Vinyl object with null
for image (reads buffer from provided filepath)
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 using npm run lint
and test via npm test
.
Donating
Support this project and others by twolfson via donations.
http://twolfson.com/support-me
License
Copyright (c) 2013 Todd Wolfson
Licensed under the MIT license.