
    i                        d Z ddlmZ ddlZddlZddlZddlmZ ddlZddl	m
Z
 e
dz  ZdZdZd	Zd
ZdZddZddZddZedk(  r e        yy)u   Venus A-5 CTA slide — PURE Gemini native image generation.

No HTML/Playwright. Korean text rendered by Gemini Pro directly.
Output: 1080x1080 PNG → /home/jay/workspace/output/meta-ads/a-group-venus/venus-A5-cta.png
    )annotationsN)Path)WORKSPACE_ROOTz.output/meta-ads/a-group-venus/venus-A5-cta.pngzgemini-3-pro-image-previewzgemini-3.1-flash-image-previewz0https://generativelanguage.googleapis.com/v1betaz3https://www.googleapis.com/auth/generative-languageu  Create a 1080x1080 square Korean premium advertising image for a Meta carousel ad. This is the final slide (5 of 5) and must be the BRIGHTEST in the series.

BACKGROUND: Photorealistic warm golden light streaming through a large window or bright doorway. Volumetric god-rays. Warm cream and white atmosphere with golden glow. Morning sunlight flooding a modern space. Conveys hope, new beginnings.

CONTENT FROM TOP TO BOTTOM:

At the very top center, a small badge reading "서울대보험쌤" in dark text on a subtle rounded pill shape.

Below that, the large bold headline in two lines, center-aligned:
"전략을 바꿀 준비가 됐다면,"
"지금 딱 한 번 물어보세요."
The headline should be in dark brown text. The words "딱 한 번" should be highlighted in gold color with an underline to draw attention.

Below the headline, the subheadline in medium-weight dark text, center-aligned:
"서울대보험쌤 팀장이 직접 답합니다."
"조건 없는 상담, 당신 상황에 맞는 방향 제시."

Below the subheadline, a large prominent CTA button with rounded corners. The button has a gold gradient background. The button text reads "무료 상담 신청하기" in DARK BROWN text (not white). The button should have a subtle shadow and look tappable.

At the bottom, small trust elements: "조건 없음 · 무료 상담 · 팀장 직접 응대" in dark text separated by middle dots.

Page indicator "5/5" in the bottom-right corner in dark gold.

CRITICAL RULES:
- ALL Korean text must be perfectly rendered with accurate characters
- All text must be large and readable on mobile
- Do NOT render any technical annotations, measurements, percentages, or pixel values in the image
- Do NOT use white text on the gold button (poor contrast). Use dark brown text instead.
- No logos, no watermarks, no internal labels
- Bright, hopeful, premium Korean advertising style
- Golden-hour photography, clean modern editorial feel
c                 f   t         j                  j                  dt        t        dz               	 dd l} | j                  t              S # t        $ r}t        d| d       Y d }~nd }~ww xY wt        j                  g ddd      }|j                  j                         }|st        d      |S )	Nr   ztools/ai-image-genz[AUTH] SA token failed: z, trying gcloud CLI...)gcloudauthzprint-access-tokenz<--scopes=https://www.googleapis.com/auth/generative-languageT)capture_outputtextz3gcloud auth print-access-token returned empty token)syspathinsertstrr   gcloud_authget_service_account_tokenGEMINI_SCOPE	Exceptionprint
subprocessrunstdoutstripRuntimeError)r   eresulttokens       [/home/jay/workspace/.worktrees/task-2116-dev1/tools/ai-image-gen/gen_venus_a5_cta_native.py	get_tokenr   :   s    HHOOAs>,@@ABD44\BB D(+ABCCD ^^	I$F
 MM!EPQQLs   A 	A-A((A-c                    t          d| d}d|  dd}ddt        igigdd	gd
dd}t        d|        t        j                  |||d      S )Nz/models/z:generateContentzBearer zapplication/json)AuthorizationzContent-Typepartsr
   IMAGETEXTg      ?)responseModalitiestemperature)contentsgenerationConfigz[API] Calling model:    )headersjsontimeout)GEMINI_API_BASEPROMPTr   requestspost)r   model_idurlr(   payloads        r   call_geminir2   M   s}    XhZ/?
@C"5'**G
  0123#*F"3
G 
!(
,-==gGSII    c                    t         j                  j                  dd       t        d       t        d       t        dt                 t        d       t        d       t	               } t        dt        |        d       t        | t              }|j                  d	v r/t        d
|j                   dt                t        | t              }|j                  s=t        d|j                   d|j                  d d         t        j                  d       |j                         }|j                  dg       }|s/t        dt!        |      d d         t        j                  d       |d   j                  di       j                  dg       }d }|D ]
  }d|v s|} n |J|D cg c]  }d|v s|j                  dd       }}t        d|d d         t        j                  d       |d   j                  dd      }	|d   d   }
t#        j$                  |
      }t         j'                  d|	v rdnd       }|j)                  |       d|	v r9dd!lm} |j/                  |      }|j1                  t         d"       t        d#       n|t         k7  r|j3                  t                t         j5                         j6                  }t        d$t                 t        d%|d&d'|d(z  d)d*       t        d+|	        dd!lm} |j/                  t               }t        d,|j8                  d    d-|j8                  d           y c c}w ).NT)parentsexist_okz<============================================================u5   Venus A-5 CTA — PURE Gemini Native Image GenerationzOutput: z
[AUTH] Obtaining token...z[AUTH] Token obtained (z chars))i  i  z[API] Pro model failed (z), falling back to z[ERROR] HTTP z: i     
candidatesz[ERROR] No candidates: i,  r   contentr    
inlineDatar
    z$[ERROR] No image in response. Text:    mimeTypez
image/jpegdatajpegz.jpgz.png)ImagePNGu   [CONVERT] JPEG → PNGz
[SUCCESS] Saved: z  Size: ,z bytes (i   z.1fz KB)z  MIME source: z  Dimensions: x)OUTPUT_PATHparentmkdirr   r   lenr2   MODEL_IDstatus_codeFALLBACK_MODEL_IDokr
   r   exitr)   getr   base64	b64decodewith_suffixwrite_bytesPILr@   opensaverenamestatst_sizesize)r   responser>   r8   r    
image_partpartp
text_parts	mime_type	image_b64image_bytesraw_pathr@   img	file_sizes                   r   mainrd   ^   s   TD9	(O	
AB	H[M
"#	(O	
'(KE	#CJ<w
785(+Hz)()=)=(>>QRcQdefu&78;;h2232hmmDS6I5JKL==?D,+J'D	$3'89:qMi,00"=EJ 4J
 16FA&A+aeeFB'F
F4Z^4DEF<(,,ZFI<(0I""9-K&&91Dv&QH%jj"e$&'{"OOK(  "**I	}
-.	HYqM)d*:3)?t
DE	OI;
'(
**[
!C	N388A;-q!
677 Gs   '	M1M__main__)returnr   )r   r   r/   r   rf   zrequests.Response)rf   None)__doc__
__future__r   rN   r   r   pathlibr   r-   
gen_configr   rD   rH   rJ   r+   r   r,   r   r2   rd   __name__ r3   r   <module>rn      sn    #   
   %OO'4 DD 
F&J">8B zF r3   