forked from kant2002/lwip
-
Notifications
You must be signed in to change notification settings - Fork 2
/
clone.js
43 lines (36 loc) · 1.26 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
/**
* 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.
*/
const lwip = require('../');
lwip.open('lena.jpg', (err, image) => {
if (err) return console.log(err);
image.batch()
.scale(0.75)
.border(5, [50, 100, 75, 75])
.exec((err, image) => {
if (err) return console.log(err);
image.clone((err, clone1) => {
if (err) return console.log('clone1:', err);
clone1.batch()
.mirror('y')
.hue(100)
.writeFile('lena_clone1.png', err => {
if (err) return console.log(err);
console.log('clone1: done');
});
});
image.clone((err, clone2) => {
if (err) return console.log('clone2:', err);
clone2.batch()
.fade(0.5)
.mirror('x')
.writeFile('lena_clone2.png', err => {
if (err) return console.log(err);
console.log('clone2: done');
});
});
});
});