"""previews/compare/lookalike_.png: the user's picture left, the render from the picture's camera right (python); previews/RobotCell__sheet.png: the other views in one sheet.""" import sys, os from PIL import Image HERE = os.path.dirname(os.path.abspath(__file__)) F = os.path.dirname(HERE) tag = sys.argv[1] if len(sys.argv) > 1 else "v01" a = Image.open(os.path.join(F, "reference", "ref_user.jpg")).convert("RGB") b = Image.open(os.path.join(F, "previews", "RobotCell_%s_picture.png" % tag)).convert("RGB").resize(a.size) c = Image.new("RGB", (a.width * 2 + 16, a.height), (255, 255, 255)) c.paste(a, (0, 0)) c.paste(b, (a.width + 16, 0)) os.makedirs(os.path.join(F, "previews", "compare"), exist_ok=True) c.save(os.path.join(F, "previews", "compare", "lookalike_%s.png" % tag)) shots = ["q_front_left", "q_back_right", "open", "robot", "tool", "pod"] ims = [] for s in shots: p = os.path.join(F, "previews", "RobotCell_%s_%s.png" % (tag, s)) if os.path.exists(p): im = Image.open(p).convert("RGB") ims.append(im.resize((800, int(800 * im.height / im.width)))) if ims: h = max(i.height for i in ims) sheet = Image.new("RGB", (3 * 810, 2 * (h + 10)), (255, 255, 255)) for k, im in enumerate(ims): sheet.paste(im, ((k % 3) * 810, (k // 3) * (h + 10))) sheet.save(os.path.join(F, "previews", "RobotCell_%s_sheet.png" % tag)) print("COMPARE OK", tag)