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_rev5.png'
prompt=('Premium cinematic semi-realistic illustrated Vietnamese audio-drama opening poster, native 16:9. EXACTLY SIX HUMAN ADULTS TOTAL, no other people anywhere, exactly three women and three men. Largest center-front protagonist is clearly a Vietnamese woman; five supporting adults are exactly two women and three men; all six faces visible. River floodplain after receding water, empty communal path, stakes, distant embankment. The woman holds a completely blank cloth with no marks, lines, symbols or writing. No papers, signs, charts or labels. Warm amber sunset, teal shadows, painterly cinematic realism. Include exactly these three readable text strings and no other text: first `ĐƯỜNG NƯỚC TRỞ VỀ`; second `Gác Mái Audio`; third `Truyện độc quyền, nghiêm cấm sao chép dưới mọi hình thức`. In the third string, the COMMA GLYPH immediately after the word `quyền` is mandatory and clearly visible. Do not omit that comma. Do not add terminal punctuation after `thức`. No other punctuation, pseudo-text, logo, seal, watermark, credits or names. No background people, boat occupants, silhouettes. No male may be 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))
