65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Create minimal placeholder PNG icons using only standard library.
|
|
These are simple solid-color squares that Firefox will accept.
|
|
"""
|
|
|
|
import struct
|
|
import zlib
|
|
from pathlib import Path
|
|
|
|
def create_png(width, height, rgb_color):
|
|
"""Create a minimal PNG file with a solid color."""
|
|
r, g, b = rgb_color
|
|
|
|
def png_chunk(chunk_type, data):
|
|
"""Create a PNG chunk with CRC."""
|
|
chunk = chunk_type + data
|
|
crc = zlib.crc32(chunk) & 0xffffffff
|
|
return struct.pack('>I', len(data)) + chunk + struct.pack('>I', crc)
|
|
|
|
# PNG signature
|
|
signature = b'\x89PNG\r\n\x1a\n'
|
|
|
|
# IHDR chunk (image header)
|
|
ihdr_data = struct.pack('>IIBBBBB', width, height, 8, 2, 0, 0, 0)
|
|
ihdr = png_chunk(b'IHDR', ihdr_data)
|
|
|
|
# IDAT chunk (image data)
|
|
# Create raw pixel data: each row starts with filter byte 0, then RGB pixels
|
|
raw_data = b''
|
|
for y in range(height):
|
|
raw_data += b'\x00' # Filter byte (none)
|
|
for x in range(width):
|
|
raw_data += bytes([r, g, b])
|
|
|
|
compressed = zlib.compress(raw_data, 9)
|
|
idat = png_chunk(b'IDAT', compressed)
|
|
|
|
# IEND chunk
|
|
iend = png_chunk(b'IEND', b'')
|
|
|
|
return signature + ihdr + idat + iend
|
|
|
|
def main():
|
|
icons_dir = Path(__file__).parent / 'icons'
|
|
icons_dir.mkdir(exist_ok=True)
|
|
|
|
# Primary blue color (#1976d2)
|
|
color = (25, 118, 210)
|
|
|
|
sizes = [16, 32, 48, 128]
|
|
|
|
for size in sizes:
|
|
png_data = create_png(size, size, color)
|
|
output_path = icons_dir / f'icon-{size}.png'
|
|
with open(output_path, 'wb') as f:
|
|
f.write(png_data)
|
|
print(f'Created {output_path} ({len(png_data)} bytes)')
|
|
|
|
print('\nPlaceholder icons created!')
|
|
print('Replace with custom icons for a better look.')
|
|
|
|
if __name__ == '__main__':
|
|
main()
|