#!/bin/sh
# Immagini creative dell'App Store (iOS 27): intestazione e risultati di ricerca,
# in italiano e inglese. Servono le schermate grezze in ../schermate/ios e
# ../en/schermate/ios (non stanno nel repository: vedi docs/store).
cd "$(dirname "$0")"
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
for l in it en; do
  s=""; [ $l = it ] || s="-$l"
  "$CHROME" --headless --disable-gpu --hide-scrollbars --allow-file-access-from-files \
    --force-device-scale-factor=1 --virtual-time-budget=8000 --window-size=3840,1646 \
    --screenshot="$PWD/intestazione$s.png" "file://$PWD/intestazione.html?l=$l" 2>/dev/null
  "$CHROME" --headless --disable-gpu --hide-scrollbars --allow-file-access-from-files \
    --force-device-scale-factor=1 --virtual-time-budget=8000 --window-size=3840,2560 \
    --screenshot="$PWD/ricerca$s.png" "file://$PWD/intestazione.html?l=$l&f=ricerca" 2>/dev/null
  "$CHROME" --headless --disable-gpu --hide-scrollbars --allow-file-access-from-files \
    --force-device-scale-factor=1 --virtual-time-budget=8000 --window-size=5244,2950 \
    --screenshot="$PWD/unico$s.png" "file://$PWD/intestazione.html?l=$l&f=unico" 2>/dev/null
done
python3 -c "
from PIL import Image
import os
A=os.path.expanduser('~/Desktop/Banner App Store/SpotTheSpy'); os.makedirs(A, exist_ok=True)
for n in ['intestazione','ricerca','unico','intestazione-en','ricerca-en','unico-en']:
    im=Image.open(n+'.png').convert('RGB'); im.save(n+'.png'); print(n, im.size)
    im.resize((1920, round(im.height*1920/im.width)), Image.LANCZOS).save(A+'/'+n+'.jpg', quality=88)"
