Project_WL/AgentScripts/WL814x_compare.py

43 lines
1.4 KiB
Python

# WL-814x 비교 이미지 생성기 — raw PNG 을 캐릭터 영역으로 잘라 1배 + N배로 가로 배치
# python AgentScripts/WL814x_compare.py <out.png> <zoom> <name1> <name2> ...
import sys, os
import numpy as np
from PIL import Image, ImageDraw
RAW = 'Screenshots_WL/WL814x/raw'
OUT = sys.argv[1]
ZOOM = int(sys.argv[2])
NAMES = sys.argv[3:]
ma = np.asarray(Image.open(RAW + '/mask_all.png').convert('L')) > 127
ys, xs = np.where(ma)
pad = 6
x0, x1 = max(0, xs.min() - pad), min(ma.shape[1], xs.max() + pad + 1)
y0, y1 = max(0, ys.min() - pad), min(ma.shape[0], ys.max() + pad + 1)
w, h = x1 - x0, y1 - y0
cells = []
for n in NAMES:
p = RAW + '/' + n + '.png'
if not os.path.exists(p):
print('missing', p); continue
im = Image.open(p).convert('RGB').crop((x0, y0, x1, y1))
big = im.resize((w * ZOOM, h * ZOOM), Image.NEAREST)
cells.append((n, im, big))
gap = 10
label = 18
W = sum(c[2].width for c in cells) + gap * (len(cells) - 1)
H = cells[0][2].height + cells[0][1].height + gap + label
out = Image.new('RGB', (W, H), (24, 24, 28))
d = ImageDraw.Draw(out)
x = 0
for n, im, big in cells:
out.paste(big, (x, label))
out.paste(im, (x + (big.width - im.width) // 2, label + big.height + gap))
d.text((x + 2, 3), n, fill=(230, 230, 230))
x += big.width + gap
os.makedirs(os.path.dirname(OUT) or '.', exist_ok=True)
out.save(OUT)
print('saved', OUT, out.size)