-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
17 lines (15 loc) · 964 Bytes
/
app.js
File metadata and controls
17 lines (15 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'use strict';
const sharp = require('sharp');
const fs = require('fs');
let svgs = ['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 16" version="1.1"><text font-family="serif" font-size="12px" x="54" y="12" fill="#000000" text-anchor="middle" >Fancy Text</text></svg>',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 16" version="1.1"><text font-family="sans-serif" font-size="12px" x="54" y="12" fill="#000000" text-anchor="middle" >Fancy Text</text></svg>',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 16" version="1.1"><text font-family="DejaVuSans" font-size="12px" x="54" y="12" fill="#000000" text-anchor="middle" >Fancy Text</text></svg>'
];
(async function () {
for (let [index, svg] of svgs.entries()) {
await sharp(Buffer.from(svg))
.toBuffer().then(buffer => {
fs.writeFile(`img/${new Date().getTime()}_${index}.png`, buffer, (err) => { });
});
}
})();