forked from hacksparrow/node-easyimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
75 lines (63 loc) · 1.44 KB
/
test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
var easyimg = require('./easyimage.js');
var srcimg = 'kitteh.jpg';
easyimg.info(srcimg, function(err, stdout, stderr) {
if (err) throw err;
console.log(stdout);
});
// test for info on a non image
easyimg.info('./test.js', function(err,stdout,stderr) {
console.log('Next line should be unsupported error');
console.log(err);
});
easyimg.convert({src:srcimg, dst:'convert.png', quality:10}, function(err, image) {
if (err) throw err;
console.log('Converted');
console.log(image);
});
easyimg.resize({src:srcimg, dst:'resize.jpg', width:640, height:480}, function(err, image) {
if (err) throw err;
console.log('Resized');
console.log(image);
});
easyimg.crop(
{
src:srcimg, dst:'crop.jpg',
cropwidth:128, cropheight:128,
gravity:'North',
x:0, y:0
},
function(err, image) {
if (err) throw err;
console.log('Cropped');
console.log(image);
}
);
easyimg.thumbnail(
{
src:srcimg, dst:'thumbnail.jpg',
width:128, height:128,
x:0, y:0
},
function(err, image) {
if (err) throw err;
console.log('Thumbnail created');
console.log(image);
}
);
easyimg.rescrop(
{
src:srcimg, dst:'rescrop.jpg',
width:500, height:500,
cropwidth:128, cropheight:128,
x:0, y:0
},
function(err, image) {
if (err) throw err;
console.log('Resized and cropped');
console.log(image);
}
);
easyimg.exec('convert '+ srcimg +' command.gif', function(err, stdout, stderr) {
if (err) throw err;
console.log('Command executed');
});