Installations
npm install gmsmith
Releases
Unable to fetch releases
Developer
twolfson
Developer Guide
Module System
CommonJS
Min. Node Version
>= 4.0.0
Typescript Support
No
Node Version
14.18.1
NPM Version
6.14.15
Statistics
10 Stars
199 Commits
11 Forks
5 Watching
1 Branches
4 Contributors
Updated on 27 Apr 2022
Languages
JavaScript (89.51%)
Shell (10.49%)
Total Downloads
Cumulative downloads
Total Downloads
1,900,866
Last day
94.3%
1,094
Compared to previous day
Last week
29.1%
5,155
Compared to previous week
Last month
10.5%
18,190
Compared to previous month
Last year
-13.2%
342,218
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
4
gmsmith
GM engine for spritesmith.
Requirements
gmsmith
depends on gm which depends on GraphicsMagick.
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.
This module has been developed and tested against 1.3.17
.
Alertnatively, you can use ImageMagick which is implicitly discovered if
gm
is not installed. http://www.imagemagick.org/script/index.php
Getting Started
Install the module with: npm install gmsmith
1// Load in our dependencies 2var Gmsmith = require('gmsmith'); 3 4// Create a new engine 5var gmsmith = new Gmsmith(); 6 7// Interpret some images from disk 8gmsmith.createImages(['img1.jpg', 'img2.png'], function handleImages (err, imgs) { 9 // If there was an error, throw it 10 if (err) { 11 throw err; 12 } 13 14 // We recieve images in the same order they were given 15 imgs[0].width; // 50 (pixels) 16 imgs[0].height; // 100 (pixels) 17 18 // Create a canvas that fits our images (200px wide, 300px tall) 19 var canvas = gmsmith.createCanvas(200, 300); 20 21 // Add the images to our canvas (at x=0, y=0 and x=50, y=100 respectively) 22 canvas.addImage(imgs[0], 0, 0); 23 canvas.addImage(imgs[1], 50, 100); 24 25 // Export canvas to image 26 var resultStream = canvas['export']({format: 'png'}); 27 resultStream; // Readable stream outputting PNG image of the canvas 28});
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
new Engine(options)
This is also known as new Gmsmith
.
Our Engine
constructor provides support for the following options:
- options
Object
- imagemagick
Boolean
- Flag to indicate whether to use ImageMagick over GraphicsMagick- When
true
, ImageMagick will be used. Otherwise, implicit discovery will be used.
- When
- imagemagick
engine.createImages(images, cb)
Our createImages
methods supports the following types of images:
- image
String
- Filepath to image - image
Object
- Vinyl object withnull
for image (uses provided filepath)
We accept but don't fully support the following types of images:
- image
Object
- Vinyl object with buffer for image (ignores contents, uses provided filepath) - image
Object
- Vinyl object with stream for image (ignores contents, uses provided filepath)
canvas.export(options)
Our export
method provides support for the following options:
- options
Object
- format
String
- Output image format to callback with. Currently, png and jpeg are available. - quality
Number
- Quality of output image on a scale from 0 to 100
- format
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE-MIT:0
- Info: FSF or OSI recognized license: MIT License: LICENSE-MIT:0
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 11 are checked with a SAST tool
Score
3.3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More