#!/usr/bin/env python3 """ Generate DIDI extension icons with white 'd' on black background """ from PIL import Image, ImageDraw, ImageFont import os # Icon sizes needed for Chrome extension SIZES = [16, 32, 48, 128] def create_icon(size): """Create a square icon with 'd' letter""" # Create black background img = Image.new('RGB', (size, size), color='#000000') draw = ImageDraw.Draw(img) # Calculate font size (roughly 60% of icon size) font_size = int(size * 0.65) # Try to use a nice font, fallback to default try: # Try common system fonts font_paths = [ 'C:/Windows/Fonts/arial.ttf', 'C:/Windows/Fonts/segoeui.ttf', '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', '/System/Library/Fonts/Helvetica.ttc' ] font = None for font_path in font_paths: if os.path.exists(font_path): font = ImageFont.truetype(font_path, font_size) break if font is None: # Fallback to default font font = ImageFont.load_default() except: font = ImageFont.load_default() # Draw white 'd' in the center text = "d" # Get text bounding box for centering bbox = draw.textbbox((0, 0), text, font=font) text_width = bbox[2] - bbox[0] text_height = bbox[3] - bbox[1] # Calculate position to center text x = (size - text_width) // 2 - bbox[0] y = (size - text_height) // 2 - bbox[1] # Draw the text draw.text((x, y), text, fill='#FFFFFF', font=font) return img def main(): """Generate all icon sizes""" script_dir = os.path.dirname(os.path.abspath(__file__)) print("Generating DIDI extension icons...") for size in SIZES: icon = create_icon(size) filename = f"icon{size}.png" filepath = os.path.join(script_dir, filename) icon.save(filepath, 'PNG') print(f"[OK] Created {filename} ({size}x{size})") print("\n[SUCCESS] All icons generated successfully!") print("\nAdd these to manifest.json:") print('"icons": {') for size in SIZES: print(f' "{size}": "icon{size}.png"{"," if size != SIZES[-1] else ""}') print('}') if __name__ == '__main__': main()