import struct import zlib import os def make_png(path, size, rgb): width = height = size r, g, b = rgb raw = bytearray() for _ in range(height): raw.append(0) # filter type 0 for each scanline for _ in range(width): raw += bytes([r, g, b]) compressed = zlib.compress(bytes(raw), 9) def chunk(tag, data): return struct.pack(">I", len(data)) + tag + data + struct.pack( ">I", zlib.crc32(tag + data) & 0xFFFFFFFF ) sig = b"\x89PNG\r\n\x1a\n" ihdr = struct.pack(">IIBBBBB", width, height, 8, 2, 0, 0, 0) png = sig + chunk(b"IHDR", ihdr) + chunk(b"IDAT", compressed) + chunk(b"IEND", b"") os.makedirs(os.path.dirname(path), exist_ok=True) with open(path, "wb") as f: f.write(png) if __name__ == "__main__": color = (31, 111, 235) # brand blue make_png("public/icons/icon-192.png", 192, color) make_png("public/icons/icon-512.png", 512, color) print("Icons generated")