Use a dict for colour mapping

This commit is contained in:
Jake Howard 2023-03-25 16:16:41 +00:00
parent 0e89d3fb48
commit 59d6bdd554
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -7,6 +7,11 @@ import os
GITEA_ROOT = "https://gitea.com"
OUTPUT_DIR = Path(__file__).parent.resolve() / "output"
COLOUR_REPLACE = {
b"#609926": b"#e85537",
b"#fff": b"#0a0a0a"
}
def download_file(url: str):
print("Downloading", os.path.basename(url))
@ -23,8 +28,9 @@ def main():
favicon = download_file(f"{GITEA_ROOT}/assets/img/favicon.svg")
print("Rebranding...")
logo = logo.replace(b"#609926", b"#e85537").replace(b"#fff", b"#0a0a0a")
favicon = favicon.replace(b"#609926", b"#e85537").replace(b"#fff", b"#0a0a0a")
for old_colour, new_colour in COLOUR_REPLACE.items():
logo = logo.replace(old_colour, new_colour)
favicon = favicon.replace(old_colour, new_colour)
print("Resizing...")
svg2png(logo, write_to=str(OUTPUT_DIR / "logo.png"), output_height=512, output_width=512)