
    _iT&                         d Z ddlZddlZddlZddlZddlZddlmZ ej                  j                  dd       ddl
Z
 ed      Zedz  Zedz  ZdZd	Zd
 Zd ZddZd Zedk(  r e        yy)uC   슬라이드 5 (CTA - Final) - T.O.P 리크루팅 캠페인 Angle A    N)Pathz&/home/jay/workspace/tools/ai-image-genz8/home/jay/workspace/output/meta-ads/angle-A/v6-benchmarkzslide-05.pngzslide-05-bg.jpgu  Bold energetic abstract background with warm orange (#EA580C) tones and dynamic shapes at the top transitioning smoothly to deep navy (#003B5C) at the bottom. Dynamic diagonal geometric shapes and light streaks suggesting forward momentum and urgent action. Abstract design — no text, no people, no logos, no watermarks. Professional but urgent atmosphere. Clean center and bottom areas for text overlay. 1080x1080 square format. Premium advertising background quality. High contrast between warm orange top and cool navy bottom.u  <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
  @import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&family=Noto+Sans+KR:wght@400;500;600;700;800;900&display=swap');

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    width: 1080px;
    height: 1080px;
    overflow: hidden;
    font-family: 'Noto Sans KR', sans-serif;
  }

  .container {
    width: 1080px;
    height: 1080px;
    position: relative;
    background: linear-gradient(180deg, #EA580C 0%, #6B2A00 35%, #1a3a52 65%, #003B5C 100%);
    overflow: hidden;
  }

  .bg-image {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }

  /* Center overlay for better text readability */
  .center-overlay {
    position: absolute;
    top: 25%;
    left: 0; right: 0;
    height: 55%;
    background: linear-gradient(
      to bottom,
      rgba(0, 20, 35, 0) 0%,
      rgba(0, 20, 35, 0.45) 50%,
      rgba(0, 20, 35, 0) 100%
    );
    pointer-events: none;
  }

  /* Bottom overlay */
  .bottom-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 45%;
    background: linear-gradient(
      to bottom,
      rgba(0, 59, 92, 0) 0%,
      rgba(0, 59, 92, 0.65) 60%,
      rgba(0, 59, 92, 0.85) 100%
    );
    pointer-events: none;
  }

  /* TOP URGENCY BADGE */
  .urgency-badge-area {
    position: absolute;
    top: 80px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .urgency-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #EA580C;
    color: #FFFFFF;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 44px;
    font-weight: 700;
    padding: 16px 40px;
    border-radius: 999px;
    letter-spacing: -0.5px;
    box-shadow: 0 4px 16px rgba(234,88,12,0.45);
  }

  /* CENTER HEADLINE */
  .headline-area {
    position: absolute;
    top: 360px;
    left: 0; right: 0;
    text-align: center;
    padding: 0 64px;
  }

  .headline-line {
    display: block;
    font-family: 'Black Han Sans', 'Noto Sans KR', sans-serif;
    font-size: 96px;
    font-weight: 900;
    color: #FFFFFF;
    line-height: 1.2;
    letter-spacing: -3px;
    text-shadow: 0 2px 20px rgba(0,0,0,0.5);
  }

  .headline-highlight {
    color: #EA580C;
  }

  /* CTA BUTTON */
  .cta-button-area {
    position: absolute;
    bottom: 200px;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
  }

  .cta-button {
    display: inline-block;
    background: #003B5C;
    color: #FFFFFF;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 48px;
    font-weight: 700;
    padding: 32px 96px;
    border-radius: 16px;
    border: 3px solid rgba(255,255,255,0.25);
    letter-spacing: -1px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }

  /* DISCLAIMER */
  .disclaimer-area {
    position: absolute;
    bottom: 120px;
    left: 0; right: 0;
    text-align: center;
    padding: 0 64px;
  }

  .disclaimer-text {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 40px;
    font-weight: 400;
    color: #CCCCCC;
    letter-spacing: -0.5px;
    line-height: 1.4;
  }
</style>
</head>
<body>
<div class="container">
  <!-- Background image -->
  <div class="bg-image" id="bg-div"></div>

  <!-- Overlays -->
  <div class="center-overlay"></div>
  <div class="bottom-overlay"></div>

  <!-- 1. URGENCY BADGE (top) -->
  <div class="urgency-badge-area">
    <span class="urgency-pill">⏰ 2026년 7월 변경 예정</span>
  </div>

  <!-- 2. HEADLINE (center) -->
  <div class="headline-area">
    <span class="headline-line">분급 전 <span class="headline-highlight">마지막</span> 혜택을</span>
    <span class="headline-line">선점하세요.</span>
  </div>

  <!-- 3. CTA BUTTON -->
  <div class="cta-button-area">
    <span class="cta-button">지금 상담 신청하기</span>
  </div>

  <!-- 4. DISCLAIMER -->
  <div class="disclaimer-area">
    <span class="disclaimer-text">모집수수료는 실적에 따라 다를 수 있습니다</span>
  </div>
</div>

<script>
function setBg(bgPath) {
  document.getElementById('bg-div').style.backgroundImage = "url('" + bgPath + "')";
}
</script>
</body>
</html>c                      ddl } 	 | j                  g dddd      }|j                  j                         }|r|S 	 t        j                         S # t        $ r Y t        j                         S w xY w)u   Gemini API 토큰 획득.r   N)gcloudauthzprint-access-tokenz<--scopes=https://www.googleapis.com/auth/generative-languageT)capture_outputtextcheck)
subprocessrunstdoutstrip	Exceptiongcloud_authget_access_token)r
   resulttokens      C/home/jay/workspace/output/meta-ads/angle-A/v06/generate_slide05.py	get_tokenr      s    
Md$   

 ##%L  ''))  ''))s   4A 	A/.A/c           	      4   d}d|  dd}ddt         igigddd	gid
}t        d       t        j                         }t        j                  |||d      }t        j                         |z
  }t        d|dd|j
                          |j
                  dvrgt        d|j
                   d       d}t        j                  |||d      }t        j                         |z
  }t        d|dd|j
                          |j
                  dk7  rt        d|j                  dd        y|j                         }|j                  dg       }	|	st        d       y|	d   j                  di       j                  dg       }
|
D ]  }d|v s|d   j                  dd       }t        j                  |d   d!         }d"|v rd#nd$}t        j                  |      }|j                  |       t        d%| d&t        |      d'd(       t        |      c S  t        d)       y)*u&   Gemini API로 배경 이미지 생성.zbhttps://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContentzBearer zapplication/json)AuthorizationzContent-Typepartsr   responseModalitiesIMAGETEXT)contentsgenerationConfigu4   배경 이미지 생성 중... (약 30-60초 소요)i,  )headersjsontimeoutu   응답 수신: z.1fu   초, 상태코드: )   u   Pro 모델 실패 (HTTP u   ), Flash 모델로 재시도...zqhttps://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-preview-image-generation:generateContentu   Flash 응답: r    u   오류 응답:Ni  
candidatesu   candidates 없음r   content
inlineDatamimeTypez
image/jpegdatajpegz.jpgz.pngu   배경 이미지 저장:  (,z bytes)u   이미지 파트 없음)	BG_PROMPTprinttimerequestspoststatus_coder   r   getbase64	b64decodeBG_PATHwith_suffixwrite_byteslenstr)r   urlr   payloadstartresponseelapsed	url_flashr%   r!   r   part	mime_typeimage_bytesextbg_save_paths                   r   generate_backgroundrB      s5   
nC"5'**G
  3456 7F"3
G 

@AIIKE}}S'MHiikE!G	OGC=(;H<P<P;Q
RS6)()=)=(>>]^_ H	==G'SVW))+%wsm+>x?S?S>TUVs"ds 34==?D,+J!"qMi,00"=E %4\*..z<HI **4+=f+EFK"i/&VC"..s3L$$[1-l^2c+>Nq=QQXYZ|$$% 

#$    c                    ddl m} t        dz  }|j                  t        d        |       5 }|j
                  j                         }	 |j                  ddd      }|j                  d	|j                          d
       | rd	|  }|j                  d| d       |j                  d       t        j                  j                  dd       |j                  t!        t              d       t#        dt                |j%                          	 ddd       |j'                  d       y# |j%                          w xY w# 1 sw Y   1xY w)u9   Playwright로 HTML 오버레이 렌더링 및 PNG 캡처.r   )sync_playwrightzslide-05-overlay.htmlzutf-8)encodingi8  )widthheight)viewportzfile://networkidle)
wait_untilzsetBg('z')i  Tparentsexist_okpng)pathtypeu   최종 이미지 저장: N)
missing_ok)playwright.sync_apirE   
OUTPUT_DIR
write_textHTML_TEMPLATEchromiumlaunchnew_pagegotoresolveevaluatewait_for_timeoutOUTPUT_PATHparentmkdir
screenshotr6   r*   closeunlink)bg_pathrE   	html_pathpbrowserpagebg_file_urls          r   render_with_playwrightrj   #  s)   344I9		 a**##%	##tt-L#MDII	 1 1 345-IP 'y1}B78!!$'$$TD$AOO[!1O>-k];<MMO!$ % MMO! s$   E
B9D/E/EEEc                     t        d       t        d       t        dt                t        d       t        j                  dd       t        d       t	               } t        dt        |        d       t        d	       t        |       }|t        d
       t        d       t        |       t        j                         j                  dz  }t        dt         d|dd       t        d       y )Nz<============================================================u*   슬라이드 5 (CTA - Final) 생성 시작u   출력 경로: TrL   u&   
[1단계] Gemini API 토큰 획득...u   토큰 획득 성공: z charsu%   
[2단계] 배경 이미지 생성...uH   배경 이미지 생성 실패 - CSS 그라디언트 배경으로 진행u)   
[3단계] HTML 오버레이 렌더링...i   u	   
완료: r'   z.0fz KB))
r*   r^   rT   r`   r   r5   rB   rj   statst_size)r   rd   size_kbs      r   mainro   ?  s    	(O	
67	OK=
)*	(OTD1 

34KE	"3u:,f
56	
23!%(GXY 

677# ((4/G	J{m2gc]$
78	(OrC   __main__)N)__doc__sysr0   r,   r+   ospathlibr   rP   insertr   rT   r^   r2   r)   rV   r   rB   rj   ro   __name__ rC   r   <module>rx      s    I 
    	  ; < LM
>)
(
(j 
~B*"2j&88 zF rC   