forked from EyalAr/lwip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clone.js
44 lines (37 loc) · 1.32 KB
/
clone.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
/**
* Example for using LWIP to clone an image.
* 1. Do some initial manipulations on the image.
* 2. Clone 2 separate images.
* 3. Do some more different manipulations in the clones.
*/
var path = require('path'),
lwip = require('../');
lwip.open('lena.jpg', function(err, image) {
if (err) return console.log(err);
image.batch()
.scale(0.75)
.border(5, [50, 100, 75, 75])
.exec(function(err, image) {
if (err) return console.log(err);
image.clone(function(err, clone1) {
if (err) return console.log("clone1:", err);
clone1.batch()
.mirror('y')
.hue(100)
.writeFile('lena_clone1.png', function(err) {
if (err) return console.log(err);
console.log('clone1: done');
});
});
image.clone(function(err, clone2) {
if (err) return console.log("clone2:", err);
clone2.batch()
.fade(0.5)
.mirror('x')
.writeFile('lena_clone2.png', function(err) {
if (err) return console.log(err);
console.log('clone2: done');
});
});
});
});