import os
from PIL import Image
R = "raw/uishot_gfx_%s.png"
os.makedirs("img", exist_ok=True)
full = ["ville_avant", "ville_apres", "avant", "apres", "ombres_off", "ombres", "brume_egout_off", "brume_egout",
        "cit_jour", "cit_soir", "cit_nuit", "lune", "nuit_off", "nuit_on", "ombres_lampes_off", "ombres_lampes",
        "lampe_on", "lampe_ombre", "lampes", "pluie_off", "pluie_on", "orage", "ruissellement", "mouille", "eau_midi",
        "courant", "egout", "gaz", "zone", "brillant", "brillant_jour", "vitres_nuit", "feu", "oeil_ebloui",
        "oeil_habitue", "gouttes", "masque", "photo"]
crops = {"ombres_fines_off": (380, 300, 1446, 900), "ombres_fines": (380, 300, 1446, 900),
         "usure_off": (0, 0, 1066, 600), "usure": (0, 0, 1066, 600), "traces": (300, 250, 1366, 850)}
total = 0
for n in full + list(crops):
    im = Image.open(R % n).convert("RGB")
    if n in crops: im = im.crop(crops[n])
    out = "img/%s.jpg" % n
    im.save(out, quality=80, optimize=True, progressive=True)
    total += os.path.getsize(out)
print(len(full) + len(crops), "images,", round(total / 1e6, 1), "Mo")
