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_rev4.png'
prompt=('Premium cinematic semi-realistic illustrated Vietnamese audio-drama opening poster, native 16:9. EXACTLY SIX HUMAN ADULTS TOTAL IN THE ENTIRE IMAGE, no other people anywhere: no boat occupants, no distant pedestrians, no silhouettes, no background figures. Exactly three women and three men. The largest centered foreground protagonist is clearly a Vietnamese woman, Võ Thanh Hà, with five supporting adults behind her: exactly two women and three men. All six full faces visible. River floodplain after receding water, empty communal boat path, survey stakes and distant embankment landscape. The woman holds a completely blank rolled cloth/map with absolutely no marks, lines, symbols or writing. No papers, signs, books, documents, charts, labels or objects containing text. Warm amber sunset, teal shadows, painterly cinematic realism, serious editorial campaign. No photography, plastic 3D, flat clip-art. Include exactly three clean readable text strings and no other text, no punctuation attached: ĐƯỜ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 pseudo-text, no logos, no seals, no watermark, no credits, no names. Do not make any male central or largest.')
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))
