-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpicprocessor.js
More file actions
executable file
·30 lines (26 loc) · 877 Bytes
/
picprocessor.js
File metadata and controls
executable file
·30 lines (26 loc) · 877 Bytes
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
const EventEmitter = require('events');
var gm = require('gm');
var Constants = require('./constants');
class PicProcessor extends EventEmitter {
constructor(camera) {
super();
this.camera = camera;
}
process(filename, doEmit, annotation) {
gm("./public/photos/" + filename)
.fill("white")
.stroke("none")
.font("Helvetica.ttf", 25)
.box("red")
.drawText(30, 20, annotation, "SouthEast")
.write("./public/photos/" + filename, (err) => {
if (err) {
console.log("Unable to annotate picture: " + err);
}
if (doEmit) {
this.camera.emit("processingDone", { filename: filename });
}
});
}
};
module.exports = PicProcessor;