forked from aheckmann/gm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalpha.js
41 lines (35 loc) · 912 Bytes
/
alpha.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
var assert = require('assert');
var async = require('async');
module.exports = function (_, dir, finish, gm, im) {
if (!gm.integration) return finish();
var alphaTypes = [
"Activate",
"On",
"Deactivate",
"Off",
"Set",
"Opaque",
"Transparent",
"Extract",
"Copy",
"Shape",
"Background"
];
// alpha not supported by GM so only test IM
if (!im) {
assert.throws(function() {
gm(dir + '/edge.png')
.alpha( alphaTypes.pop() ).write(dir+'/alpha_fail.png');
});
finish();
} else {
async.eachSeries(alphaTypes,function(alphaType,cb) {
var m = gm(dir + '/edge.png').options({imageMagick: im}).alpha( alphaType );
var args = m.args();
assert.equal('convert', args[0]);
assert.equal('-alpha', args[2]);
assert.equal(alphaType, args[3]);
m.write( dir + '/alpha_' + alphaType + '.png', cb);
},finish);
}
}