frames.py 605 B

1234567891011
  1. #!/usr/bin/env python3
  2. """frames.py <id> <ours.png> <out.png> - all WE ref frames + ours in one grid (for animated items)"""
  3. import glob, os, sys
  4. from PIL import Image
  5. id_, ours, out = sys.argv[1:4]
  6. fs = sorted(glob.glob(os.path.expanduser(f'~/.local/share/we_live/refs/{id_}/f*.png')))
  7. ims = [Image.open(f).convert('RGB').crop((4, 30, 1920, 1080)) for f in fs] + [Image.open(ours).convert('RGB').crop((0, 0, 1916, 1050))]
  8. g = Image.new('RGB', (1920, 350 * ((len(ims) + 2) // 3)), (255, 0, 255))
  9. for i, im in enumerate(ims):
  10. g.paste(im.resize((638, 350)), ((i % 3) * 640, (i // 3) * 350))
  11. g.save(out)