-
Notifications
You must be signed in to change notification settings - Fork 0
/
pax.js
35 lines (30 loc) · 814 Bytes
/
pax.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
var fs = require('fs');
var template = `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Example</title>
</head>
<body>
<div>
<div><img src="{layer1}"></div>
<div><img src="{layer2}"></div>
<div><img src="{layer3}"></div>
<div><img src="{layer4}"></div>
<div><img src="{layer5}"></div>
<div><img src="{layer6}"></div>
</div>
</body>
</html>
`;
var myArgs = process.argv.slice(2);
var folder = myArgs[0];
fs.readdirSync(folder).forEach((file, i) => {
var bitmap = fs.readFileSync(`${folder}/${file}`);
var base64 = new Buffer(bitmap).toString('base64');
template = template.replace(`{layer${i+1}}`, `data:image/png;base64, ${base64}`)
});
fs.writeFile("index.html", template, function (err) {
if (err) return console.log(err);
console.log('Success');
});