-
Notifications
You must be signed in to change notification settings - Fork 0
/
itxt.js
37 lines (33 loc) · 970 Bytes
/
itxt.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
const itxt = require('png-itxt');
const fs = require('fs');
console.log(itxt);
// var chunk = new itxt ({
var chunk = {
keyword: 'openbadges',
value: 'value',
compression: 0,
compressionMethod: 0,
languageTag: '',
translatedKeyword: '',
text: {key:'value'}
// });
};
console.log(chunk);
fs.createReadStream('images/rookie-badge-issuer.png')
.pipe(itxt.set(chunk))
// .pipe(itxt.set(JSON.stringify(chunk)))
.pipe(fs.createWriteStream('images/output.png'));
fs.createReadStream('images/rookie-badge-issuer.png')
.pipe(itxt.get(function (err, data) {
if (!err && data) {
console.log(data.keyword, ':', data.value);
}
console.log('Nothing to see here');
}));
fs.createReadStream('images/output.png')
.pipe(itxt.get(function (err, data) {
if (!err && data) {
console.log(data.keyword, ':', data.value);
}
console.log('Okay we are done');
}));