RU
games/dmmotor / tools / site / make-images.py · commit 9d248a4
#!/usr/bin/env python3"""dmmotor: the site's pictures from the game's screenshots (nearest neighbour scaling only)."""import osfrom PIL import ImageGAME = os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..'))SHOTS = os.path.join(GAME, 'var', 'screenshots')OUT = os.path.join(GAME, 'site', 'images')os.makedirs(OUT, exist_ok=True)def shot(name):    return Image.open(os.path.join(SHOTS, name)).convert('RGB')pictures = {    'title.png': shot('site/title.png'),    'shot-zombie.png': shot('tests/Tests.PlayTest-testThePistolKillsAZombieInFront.png'),    'shot-door.png': shot('tests/Tests.PlayTest-testUsingADoorOpensIt.png'),    'shot-imp.png': shot('tests/Tests.PlayTest-testAnImpFireballHurtsThePlayer.png'),    'shot-e1m2.png': shot('site/e1m2.png'),    'shot-stats.png': shot('tests/Tests.PlayTest-testTheExitSwitchEndsTheLevel.png'),}for name, im in pictures.items():    im.save(os.path.join(OUT, name), optimize=True)# Open Graph 1200 x 630: the game screen scaled x2 (nearest), cropped in the middledoor = pictures['shot-door.png'].resize((1280, 960), Image.NEAREST)og = door.crop((40, 60, 1240, 690))og.save(os.path.join(OUT, 'og.png'), optimize=True)# directory picture, 16:9thumb = pictures['shot-imp.png'].crop((0, 60, 640, 420))thumb.save(os.path.join(GAME, 'assets', 'thumbnail.png'), optimize=True)# favicon: the face of the status barface = pictures['shot-zombie.png'].crop((288, 408, 350, 470)).resize((64, 64), Image.NEAREST)face.save(os.path.join(OUT, 'favicon.png'), optimize=True)face.save(os.path.join(GAME, 'assets', 'icon.png'), optimize=True)print('site images:', ', '.join(sorted(os.listdir(OUT))))