forked from kant2002/lwip
-
Notifications
You must be signed in to change notification settings - Fork 2
/
extract.js
38 lines (31 loc) · 1.12 KB
/
extract.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
/**
* Example for using LWIP to extract parts of an image.
*/
const lwip = require('../');
lwip.open('lena.jpg', (err, image) => {
if (err) return console.log(err);
image.extract(230, 230, 370, 300, (err, eyes) => {
eyes.writeFile('lena_eyes.jpg', err => {
if (err) return console.log('eyes:', err);
console.log('eyes: done');
});
eyes.extract(0, 0, 70, 71, (err, left_eye) => {
left_eye.writeFile('lena_eyes_left.jpg', err => {
if (err) return console.log('eyes left:', err);
console.log('eyes left: done');
});
});
eyes.extract(71, 0, 141, 71, (err, right_eye) => {
right_eye.writeFile('lena_eyes_right.jpg', err => {
if (err) return console.log('eyes right:', err);
console.log('eyes right: done');
});
});
});
image.extract(240, 320, 350, 380, (err, eyes) => {
eyes.writeFile('lena_mouth.jpg', err => {
if (err) return console.log('mouth:', err);
console.log('mouth: done');
});
});
});