Use a dict for colour mapping
This commit is contained in:
parent
0e89d3fb48
commit
59d6bdd554
1 changed files with 8 additions and 2 deletions
10
resize.py
10
resize.py
|
@ -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)
|
||||
|
|
Reference in a new issue