forked from aheckmann/gm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (46 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// gm - Copyright Aaron Heckmann <[email protected]> (MIT Licensed)
/**
* Module dependencies.
*/
var escape = require('./lib/utils').escape;
/**
* Constructor.
*
* @param {String|Number} path - path to img source or width of img to create
* @param {Number} [height] - optional height of img to create
* @param {String} [color] - optional hex background color of created img
*/
function gm (source, height, color) {
var width;
if (!(this instanceof gm)) {
return new gm(source, height, color);
}
this.data = {};
this._in = [];
this._out = [];
if (height) {
// new images
width = source;
source = "";
this.in("-size", width + "x" + height);
if (color) {
this.in("xc:"+ color);
}
} else {
source = escape(source);
}
this.source = source;
}
/**
* Augment the prototype.
*/
require("./lib/getters")(gm.prototype);
require("./lib/args")(gm.prototype);
require("./lib/drawing")(gm.prototype);
require("./lib/convenience")(gm.prototype);
require("./lib/command")(gm.prototype);
/**
* Expose.
*/
module.exports = gm;
module.exports.version = "0.5.0";