#!/usr/bin/env python3
from PIL import Image
from pathlib import Path
import hashlib, json
R=Path('/data/video-pipeline/GacMaiAudio/project/gacmai_20260718_075153')
I=R/'assets/images'

def panel(path):
    src=Image.open(path).convert('RGB')
    scale=min(600/src.width,1080/src.height)
    size=(round(src.width*scale),round(src.height*scale))
    resized=src.resize(size,Image.Resampling.LANCZOS)
    canvas=Image.new('RGB',(600,1080),(12,24,25))
    canvas.paste(resized,((600-size[0])//2,(1080-size[1])//2))
    return canvas
left=panel(I/'left_campaign_rev1.png')
right=panel(I/'right_campaign_rev1.png')
out=Image.new('RGB',(1920,1080),(0,255,0))
out.paste(left,(0,0));out.paste(right,(1320,0))
p=I/'main_frame_campaign_rev1.png';out.save(p,format='PNG')
pix=out.load();center=sum(1 for y in range(1080) for x in range(600,1320) if pix[x,y]==(0,255,0));outside=sum(1 for y in range(1080) for x in list(range(0,600))+list(range(1320,1920)) if pix[x,y]==(0,255,0))
assert center==777600 and outside==0
print(json.dumps({'status':'passed','path':str(p),'sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'size':out.size,'green_center_pixels':center,'green_outside_pixels':outside}))
