Background fill the .ico

- Add additional ignores/msbuild deletes to icon gen script
This commit is contained in:
Jordan Dominion
2023-09-14 20:42:00 -04:00
parent d3c8594297
commit e8d83c6e9b
4 changed files with 22 additions and 8 deletions
+2
View File
@@ -30,3 +30,5 @@ packaging/
/src/Tgstation.Server.Common/node_modules
/src/Tgstation.Server.Common/package.json
/src/Tgstation.Server.Common/yarn.lock
/src/Tgstation.Server.Common/logo_bg_white.svg
yarn-error.log*
+5 -1
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 14 KiB

@@ -10,7 +10,7 @@
</PropertyGroup>
<!-- This is here because I know we have node as a build dep so this just works -->
<Target Name="IconGeneration" BeforeTargets="ResolveAssemblyReferences" Inputs="../../build/logo.svg" Outputs="../../artifacts/tgs.ico;../../artifacts/tgs.png">
<Target Name="IconGeneration" BeforeTargets="ResolveAssemblyReferences" Inputs="build_logo.js;../../build/logo.svg" Outputs="../../artifacts/tgs.ico;../../artifacts/tgs.png">
<Message Text="Restoring yarn packages..." Importance="high" />
<Exec Command="npx --yes yarn add svg-to-ico@1.0.14 svg2img@1.0.0-beta.2" />
<Message Text="Generating icons from SVG..." Importance="high" />
@@ -24,6 +24,6 @@
<Target Name="IconNodeCleanup" AfterTargets="IconGeneration;IconClean">
<RemoveDir Directories="node_modules" />
<Delete Files="package.json;yarn.lock" />
<Delete Files="package.json;yarn.lock;logo_bg_white.svg;yarn-error.log" />
</Target>
</Project>
+13 -5
View File
@@ -1,6 +1,6 @@
// Prereq packages: svg-to-ico@1.0.14 svg2img@1.0.0-beta.2
// Usage: node ./build_logo.js
// Generates ../../artifacts/tgs.ico and ../../artifacts/tgs.ico
// Generates ../../artifacts/tgs.ico and ../../artifacts/tgs.ico
const svg_to_img = require("svg-to-ico");
const svg2img = require('svg2img');
@@ -10,12 +10,19 @@ if (!fs.existsSync("../../artifacts")) {
fs.mkdirSync("../../artifacts",'0777', true);
}
const svg_bytes = fs.readFileSync("../../build/logo.svg");
const svg = svg_bytes.toString();
const white_bg_svg = svg
.replace("<!-- DO NOT CHANGE THIS LINE, UNCOMMENTING IT ENABLES THE WHITE BACKGROUND FOR THE .ICO--><!--", "")
.replace("SCRIPT_REPLACE_TOKEN", "");
fs.writeFileSync("logo_white_bg.svg", white_bg_svg);
svg_to_img({
input_name: "../../build/logo.svg",
input_name: "logo_white_bg.svg",
output_name: "../../artifacts/tgs.ico",
sizes: [ 160 ]
}).then(() => {
// this package sucks, path separators are fucked
fs.unlinkSync("logo_white_bg.svg");
svg2img(
"../../build/logo.svg",
{
@@ -35,6 +42,7 @@ svg_to_img({
fs.writeFileSync("../../artifacts/tgs.png", buffer);
});
}).catch((error) => {
console.error(`ICO conversion failed: ${error}`);
exit(1);
fs.unlinkSync("logo_white_bg.svg");
console.error(`ICO conversion failed: ${error}`);
exit(1);
});