-
Notifications
You must be signed in to change notification settings - Fork 8
/
convert.js
executable file
·87 lines (82 loc) · 1.54 KB
/
convert.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/node
const image2base64 = require('image-to-base64');
const fs = require('fs');
const images = [
{
name: 'smartphone',
file: 'images/black/smartphone.png',
},
{
name: 'server',
file: 'images/black/server.png',
},
{
name: 'database',
file: 'images/black/database.png',
},
{
name: 'person',
file: 'images/black/person.png',
},
{
name: 'worker',
file: 'images/black/worker.png',
},
{
name: 'cloud',
file: 'images/black/cloud.png',
},
{
name: 'notebook',
file: 'images/black/notebook.png',
},
{
name: 'desktop',
file: 'images/black/desktop.png',
},
{
name: 'webpage',
file: 'images/black/webpage.png',
},
{
name: 'pod',
file: 'images/black/pod.png',
},
{
name: 'document',
file: 'images/black/document.png',
},
{
name: 'phone',
file: 'images/black/phone.png',
},
{
name: 'folder',
file: 'images/black/folder.png',
},
];
const cv = async function(image) {
return {
name: image.name,
data: await image2base64(image.file),
};
};
const run2 = async function() {
const imagesData = [];
for (const image of images) {
imagesData.push(await cv(image));
}
const stream = fs.createWriteStream('icons.js', {flags: 'w'});
stream.write('const DiagramIcons = {\n');
imagesData.map((image) => {
stream.write(' ' + image.name + ': ' +
'"data:image/png;base64,' + image.data + '",\n');
});
stream.write('};\n');
stream.end;
};
try {
run2();
} catch (e) {
console.log(e);
}