mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
generate more pngs
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
0b9085cf3f
commit
f7a567f07c
1 file changed
+15
-2
@@ -17,18 +17,31 @@ const svgData = readFileSync(inputFile, { encoding: "utf-8" });
|
|||||||
const svgDom = new JSDOM(`<body>${svgData}</body>`);
|
const svgDom = new JSDOM(`<body>${svgData}</body>`);
|
||||||
const svgRoot = svgDom.window.document.body.getElementsByTagName("svg")[0];
|
const svgRoot = svgDom.window.document.body.getElementsByTagName("svg")[0];
|
||||||
|
|
||||||
|
svgRoot.innerHTML += `<style>* {fill: white !important;}</style>`;
|
||||||
|
const lightTemplate = svgRoot.outerHTML;
|
||||||
|
|
||||||
svgRoot.innerHTML += `<style>* {fill: black !important;}</style>`;
|
svgRoot.innerHTML += `<style>* {fill: black !important;}</style>`;
|
||||||
|
|
||||||
|
const darkTemplate = svgRoot.outerHTML;
|
||||||
|
|
||||||
console.log("Generating tray icon pngs");
|
console.log("Generating tray icon pngs");
|
||||||
|
|
||||||
ensureDirSync(outputFolder);
|
ensureDirSync(outputFolder);
|
||||||
|
|
||||||
Promise.allSettled([
|
Promise.allSettled([
|
||||||
sharp(Buffer.from(svgRoot.outerHTML))
|
sharp(Buffer.from(darkTemplate))
|
||||||
|
.resize({ width: size, height: size })
|
||||||
|
.png()
|
||||||
|
.toFile(path.join(outputFolder, "trayIconDarkTemplate.png")),
|
||||||
|
sharp(Buffer.from(darkTemplate))
|
||||||
|
.resize({ width: size*2, height: size*2 })
|
||||||
|
.png()
|
||||||
|
.toFile(path.join(outputFolder, "trayIconDarkTemplate@2x.png")),
|
||||||
|
sharp(Buffer.from(lightTemplate))
|
||||||
.resize({ width: size, height: size })
|
.resize({ width: size, height: size })
|
||||||
.png()
|
.png()
|
||||||
.toFile(path.join(outputFolder, "trayIconTemplate.png")),
|
.toFile(path.join(outputFolder, "trayIconTemplate.png")),
|
||||||
sharp(Buffer.from(svgRoot.outerHTML))
|
sharp(Buffer.from(lightTemplate))
|
||||||
.resize({ width: size*2, height: size*2 })
|
.resize({ width: size*2, height: size*2 })
|
||||||
.png()
|
.png()
|
||||||
.toFile(path.join(outputFolder, "trayIconTemplate@2x.png")),
|
.toFile(path.join(outputFolder, "trayIconTemplate@2x.png")),
|
||||||
|
|||||||
Reference in new issue
Block a user