-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
35 lines (26 loc) · 856 Bytes
/
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
"use strict";
var mgwnd = require('./build/Release/magickwand');
var magickwand = {
resize: function(imagefile, options, cb) {
if (Object.keys(options).length == 0) {
return cb(new Error('Invalid width/height/format/quality arguments'));
}
[ 'quality', 'width', 'height' ].forEach(function(param) {
if (!options[param])
options[param] = 0;
});
mgwnd.resize(imagefile,options.width,options.height,options.quality,options.format,cb);
},
thumbnail: function(imagefile, options, cb) {
var args = {};
if (typeof(cb) != 'function') {
cb = options;
options = {};
}
[ 'width', 'height', 'quality' ].forEach(function(param) {
args[param] = options[param] || 0;
});
mgwnd.thumbnail(imagefile,args.width,args.height,args.quality,cb);
}
};
module.exports = magickwand;