didi-lot3-frontend/extension/generate_icons.py
Top Clossers cec967f953 Livrare Lot 3 (Frontend): aplicație web, aplicație mobilă Android, extensie browser
- Surse complete web (React/Vite) + mobil (React Native/Expo) + extensie (MV3)
- Documentație de livrare: ghid utilizare, matrice trasabilitate cerințe, raport testare furnizor
- Artefacte binare: imagine Docker didi-frontend:lot3-1.0, APK, extensie v3.2.6 + SHA256SUMS
- Configurare adresă platformă externalizată (build args / .env / config.js)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 12:40:40 +03:00

81 lines
2.3 KiB
Python

#!/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()