import os, sys, json, hashlib
from pathlib import Path

def load_env(path):
    for line in Path(path).read_text(errors='ignore').splitlines():
        line=line.strip()
        if not line or line.startswith('#') or '=' not in line: continue
        k,v=line.split('=',1); os.environ.setdefault(k.strip(),v.strip().strip('"\''))
load_env('/opt/OpenMontage/.env'); sys.path.insert(0,'/opt/OpenMontage')
from tools.graphics.cx_image import CXImage
P='gacmai_20260718_075153'; R=Path('/data/video-pipeline/GacMaiAudio/project')/P; out=R/'assets/images/intro_campaign_rev2.png'
prompt='Premium cinematic semi-realistic illustrated Vietnamese audio-drama opening poster, native 16:9. Exactly six Vietnamese adults: exactly three women and three men. The dominant protagonist MUST be a clearly female Vietnamese adult woman, Võ Thanh Hà, centered in front and substantially larger/brighter than all others, holding a rolled floodplain map. Five supporting adults behind her: exactly two women and three men. All six full faces visible. Broad river floodplain after receding water, communal boat path, survey stakes and distant embankment plan. Warm amber sunset, teal shadows, painterly cinematic realism, serious editorial campaign. No photography, no plastic 3D, no flat clip-art. Include exactly these three readable strings and absolutely no other text: ĐƯỜNG NƯỚC TRỞ VỀ; Gác Mái Audio; Truyện độc quyền, nghiêm cấm sao chép dưới mọi hình thức. No documents with writing, pseudo-text, seals, logos, watermark, names or credits. Do not make any male the central or largest subject.'
r=CXImage().execute({'prompt':prompt,'model':'cx/gpt-5.5-image','size':'1920x1080','quality':'high','background':'auto','image_detail':'high','output_format':'png','n':1,'output_path':str(out)})
if not r.success: raise SystemExit(r.error)
print(json.dumps({'status':'passed','file':str(out),'sha256':hashlib.sha256(out.read_bytes()).hexdigest(),'provider':r.data.get('provider'),'model':r.model},ensure_ascii=False))
