forked from aheckmann/gm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.js
61 lines (48 loc) · 1.69 KB
/
options.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
var assert = require('assert')
, fs = require('fs')
module.exports = function (_, dir, finish, gm) {
var sub = gm.subClass({ subclassed: true });
var s = sub('test').options({ setWithMethod: 2 });
var g = gm('test').options({ hellowwww: 'there' });
assert.equal(2, s._options.setWithMethod);
assert.equal(true, s._options.subclassed);
assert.equal('there', g._options.hellowwww);
assert.equal(undefined, g._options.setWithMethod);
assert.equal(undefined, s._options.hellowwww);
assert.equal(undefined, g._options.subclassed);
/// subclass options
var s2 = sub('another');
assert.equal(true, s2._options.subclassed);
assert.equal(undefined, s2._options.setWithMethod);
var writeFile = dir + '/IM-negative' + Math.random() + '.png';
var imageMagick = gm.subClass({ imageMagick: true });
if (!gm.integration)
return finish();
imageMagick(dir + '/photo.JPG')
.negative()
.write(writeFile, function (err, _1, _2, cmd) {
if (err) return finish(err);
assert.ok(/^convert /.test(cmd));
fs.stat(writeFile, function (err) {
if (err) return finish(new Error('imagemagick did not write file'));
try {
fs.unlinkSync(writeFile);
} catch (e) {}
/// inline options
gm(dir + '/photo.JPG')
.negative()
.options({ imageMagick: true })
.write(writeFile, function (err, _1, _2, cmd) {
if (err) return finish(err);
assert.ok(/^convert /.test(cmd));
fs.stat(writeFile, function (err) {
if (err) return finish(new Error('imagemagick did not write file'));
try {
fs.unlinkSync(writeFile);
} catch (e) {}
finish();
});
});
});
});
}