#!/usr/bin/env python3 """Generate the Store logo tiles from the app's own brand artwork. The MSIX manifest references four images that must exist inside the package (50x50 StoreLogo, 44x44, 150x150, 310x150 wide). They are derived from `Assets/llamacasty-logo.jpg` — the same artwork the app shows in the overlay — so the listing art and the app art cannot drift apart. The bright mark is located by luminance (the artwork is a dark navy field with a light mark in the middle), cropped, and re-laid on the artwork's own background colour so the tiles look like the app. Run: python3 scripts/make-store-logos.py """ import os from PIL import Image ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SOURCE = os.path.join(ROOT, "Assets", "llamacasty-logo.jpg") OUT_DIR = os.path.join(ROOT, "Packaging", "Assets") def background(image: Image.Image) -> tuple: """The artwork's own background colour (a corner pixel).""" return image.getpixel((4, 4)) def mark_crop(image: Image.Image) -> tuple: """The bbox of the light mark, found by luminance threshold.""" grey = image.convert("L") bright = grey.point(lambda p: 255 if p > 190 else 0) bbox = bright.getbbox() if bbox is None: raise SystemExit("no bright mark found in the source artwork") return bbox def tile(image: Image.Image, crop: tuple, size: int) -> Image.Image: """A square tile: the mark scaled to fit, on the artwork's background.""" canvas = Image.new("RGB", (size, size), background(image)) mark = image.crop(crop) scale = size / max(mark.size) mark = mark.resize((max(1, int(mark.width * scale)), max(1, int(mark.height * scale)))) canvas.paste(mark, ((size - mark.width) // 2, (size - mark.height) // 2)) return canvas def wide(image: Image.Image, crop: tuple, width: int, height: int) -> Image.Image: """A wide tile: the mark at the artwork's height, centred on the background.""" canvas = Image.new("RGB", (width, height), background(image)) mark = image.crop(crop) scale = height / mark.height mark = mark.resize((max(1, int(mark.width * scale)), height)) canvas.paste(mark, ((width - mark.width) // 2, 0)) return canvas def main() -> None: os.makedirs(OUT_DIR, exist_ok=True) image = Image.open(SOURCE).convert("RGB") crop = mark_crop(image) print(f"source {SOURCE} {image.size}, mark at {crop}") outputs = { "StoreLogo.png": tile(image, crop, 50), "Square44x44Logo.png": tile(image, crop, 44), "Square150x150Logo.png": tile(image, crop, 150), "Square310x310Logo.png": tile(image, crop, 310), "Wide310x150Logo.png": wide(image, crop, 310, 150), } for name, canvas in outputs.items(): path = os.path.join(OUT_DIR, name) canvas.save(path, "PNG") print(f"wrote {os.path.relpath(path, ROOT)} {canvas.size}") if __name__ == "__main__": main()