44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
import os
|
|
from PIL import Image
|
|
|
|
def process_screenshots():
|
|
raw_files = [
|
|
('/tmp/raw_01_login.png', 'store_listing/graficos/01_login.png'),
|
|
('/tmp/raw_02_inicio.png', 'store_listing/graficos/02_inicio.png'),
|
|
('/tmp/raw_03_ruta.png', 'store_listing/graficos/03_ruta.png'),
|
|
('/tmp/raw_04_pedidos.png', 'store_listing/graficos/04_pedidos.png'),
|
|
('/tmp/raw_05_catalogo.png', 'store_listing/graficos/05_catalogo.png'),
|
|
('/tmp/raw_06_perfil.png', 'store_listing/graficos/06_perfil.png'),
|
|
]
|
|
|
|
# Mathematical crop: (0, 152, 1344, 152 + 2688)
|
|
# Removes top status bar (152px) and bottom system bar (152px) symmetrically
|
|
crop_box = (0, 152, 1344, 152 + 2688)
|
|
|
|
for src, dest in raw_files:
|
|
if not os.path.exists(src):
|
|
print(f"File not found: {src}")
|
|
continue
|
|
|
|
im = Image.open(src)
|
|
w, h = im.size
|
|
print(f"Processing {src}: original size {w}x{h}")
|
|
|
|
# Crop to exact 2:1 aspect ratio
|
|
cropped = im.crop(crop_box)
|
|
# Convert to RGB (no unnecessary alpha channel for store screenshots)
|
|
if cropped.mode == 'RGBA':
|
|
bg = Image.new('RGB', cropped.size, (255, 255, 255))
|
|
bg.paste(cropped, mask=cropped.split()[3])
|
|
cropped = bg
|
|
else:
|
|
cropped = cropped.convert('RGB')
|
|
|
|
cropped.save(dest, 'PNG', optimize=True)
|
|
cw, ch = cropped.size
|
|
ratio = ch / cw
|
|
print(f"Saved: {dest} ({cw}x{ch}, aspect ratio {ratio:.2f}:1)")
|
|
|
|
if __name__ == '__main__':
|
|
process_screenshots()
|