"""previews/compare/lookalike_.png: the user's picture left, the front render right, same framing (python).""" 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.png")).convert("RGB") b = Image.open(os.path.join(F, "previews", "NutritionFeeder_%s_front.png" % tag)).convert("RGB").resize(a.size) if "--bloom" in sys.argv: # a bloom pass like the game engine's on the blue lights (the picture has one) from PIL import ImageFilter, ImageChops import numpy as np x = np.asarray(b).astype(np.float32) lum = x.max(2) blue = (x[..., 2] > 200) & (x[..., 1] > 170) & (x[..., 2] - x[..., 0] > 40) blue[:650, :] = False # not on the screen: its glow is drawn into the UI m = np.where(blue[..., None], x, 0).astype(np.uint8) g = Image.fromarray(m) g = ImageChops.add(Image.eval(g.filter(ImageFilter.GaussianBlur(6)), lambda v: int(v * 0.9)), Image.eval(g.filter(ImageFilter.GaussianBlur(18)), lambda v: int(v * 0.7))) b = ImageChops.add(b, g) 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%s.png" % (tag, "_bloom" if "--bloom" in sys.argv else ""))) # zoom on the cavity, both z = Image.new("RGB", (2 * 600 + 16, 640), (255, 255, 255)) z.paste(a.crop((390, 640, 990, 1280)), (0, 0)); z.paste(b.crop((390, 640, 990, 1280)), (616, 0)) z.save(os.path.join(F, "previews", "compare", "cavity_%s%s.png" % (tag, "_bloom" if "--bloom" in sys.argv else "")))