almeira-web/scripts/generate_playstore_assets.py

95 lines
4.0 KiB
Python

import os
from PIL import Image, ImageDraw, ImageFont, ImageFilter
base_dir = r"c:\Users\Carlos\dev\almeira-web\dripzone-app"
out_dir = os.path.join(base_dir, "public", "playstore")
os.makedirs(out_dir, exist_ok=True)
print("Generando activos gráficos para Google Play Store...")
# 1. Ícono de Alta Resolución 512 x 512
icon_source = os.path.join(base_dir, "public", "icon.png")
icon_out = os.path.join(out_dir, "icon-512x512.png")
if os.path.exists(icon_source):
img_icon = Image.open(icon_source).convert("RGBA")
# Asegurar fondo negro sólido (sin canal alfa transparente según directriz de Play Store)
bg_icon = Image.new("RGBA", (512, 512), (10, 10, 10, 255))
img_icon_resized = img_icon.resize((512, 512), Image.Resampling.LANCZOS)
bg_icon.paste(img_icon_resized, (0, 0), img_icon_resized)
# Convertir a RGB (fondo opaco puro)
bg_icon.convert("RGB").save(icon_out, "PNG", quality=95)
print(f" -> [OK] Ícono 512x512 generado en: {icon_out}")
# 2. Gráfico de Funciones (Feature Graphic) 1024 x 500
feature_out = os.path.join(out_dir, "feature-graphic-1024x500.png")
# Crear fondo horizontal 1024 x 500 con gradiente luxury dark
feature_img = Image.new("RGBA", (1024, 500), (8, 8, 12, 255))
draw = ImageDraw.Draw(feature_img)
# Pintar gradiente radial/lineal de fondo sutil morado a negro
for y in range(500):
ratio = y / 500.0
r = int(12 + (30 - 12) * (1 - ratio * 0.7))
g = int(8 + (10 - 8) * (1 - ratio * 0.7))
b = int(22 + (50 - 22) * (1 - ratio * 0.7))
draw.line([(0, y), (1023, y)], fill=(r, g, b, 255))
# Decoración con círculos brillantes desenfocados (efecto neón / glow)
glow = Image.new("RGBA", (1024, 500), (0, 0, 0, 0))
glow_draw = ImageDraw.Draw(glow)
glow_draw.ellipse([262, -50, 762, 450], fill=(147, 51, 234, 45)) # Purple glow
glow_draw.ellipse([650, 100, 1050, 500], fill=(236, 72, 153, 30)) # Pink glow
glow = glow.filter(ImageFilter.GaussianBlur(50))
feature_img = Image.alpha_composite(feature_img, glow)
# Incrustar el logo/emblema central
logo_source = os.path.join(base_dir, "public", "dripzone-logo.png")
if os.path.exists(logo_source):
logo_img = Image.open(logo_source).convert("RGBA")
logo_w = 260
logo_h = int(logo_img.height * (logo_w / logo_img.width))
logo_resized = logo_img.resize((logo_w, logo_h), Image.Resampling.LANCZOS)
# Pegar centrado
pos_x = (1024 - logo_w) // 2
pos_y = 60
feature_img.paste(logo_resized, (pos_x, pos_y), logo_resized)
# Textos informativos de impacto
draw_final = ImageDraw.Draw(feature_img)
try:
font_title = ImageFont.truetype("arial.ttf", 36)
font_sub = ImageFont.truetype("arial.ttf", 18)
font_badge = ImageFont.truetype("arialbd.ttf", 15)
except:
font_title = ImageFont.load_default()
font_sub = ImageFont.load_default()
font_badge = ImageFont.load_default()
# Texto: D R I P Z O N E
title_text = "DRIPZONE LUXURY SNEAKERS"
bbox_title = draw_final.textbbox((0, 0), title_text, font=font_title)
t_w = bbox_title[2] - bbox_title[0]
draw_final.text(((1024 - t_w) // 2, 330), title_text, fill=(255, 255, 255, 255), font=font_title)
# Subtexto: Calzado Exclusivo • Pago Contraentrega en Colombia
sub_text = "Zapatillas Exclusivas • Separa con $10.000 • Pago Contraentrega en Colombia"
bbox_sub = draw_final.textbbox((0, 0), sub_text, font=font_sub)
s_w = bbox_sub[2] - bbox_sub[0]
draw_final.text(((1024 - s_w) // 2, 385), sub_text, fill=(200, 200, 220, 255), font=font_sub)
# Badge inferior: Envíos Nacionales & Garantía
badge_text = "★ CALIDAD G5 / 1.1 | 1er CAMBIO DE TALLA GRATIS | ENVÍOS NACIONALES ★"
bbox_badge = draw_final.textbbox((0, 0), badge_text, font=font_badge)
b_w = bbox_badge[2] - bbox_badge[0]
draw_final.text(((1024 - b_w) // 2, 435), badge_text, fill=(168, 85, 247, 255), font=font_badge)
# Guardar en RGB (sin canal alfa según directiva de Google)
feature_img.convert("RGB").save(feature_out, "PNG", quality=95)
print(f" -> [OK] Gráfico de Funciones 1024x500 generado en: {feature_out}")
print("\n¡Activos gráficos de Google Play Store listos con especificaciones exactas!")