
    i<                    L   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j                  j                  d e ee      j                               ddlZ ed      Zedz  Zedz  Zed	z  Z ej*                         d
z  ZdZdZdZddZddZddZedk(  r e        yy)u0  컨셉 #47 K.R Award Emotional Finance — T.O.P 리크루팅 Meta 광고.

Samsung Fire '보험 선물하기', Hanwha 감성 콜라보 캠페인 레퍼런스.
따뜻한 Warm Beige 배경 + Deep Blue 타이포그래피.
Gemini AI 배경 + HTML/CSS 텍스트 오버레이 하이브리드 파이프라인.
    )annotationsN)Path)sync_playwrightzQ/home/jay/workspace/output/meta-ads/concept-catalog/47-kr-award-emotional-financezbg.jpgz
sample.pngz!47-kr-award-emotional-finance.pngz.local/share/fonts/Pretendardz0https://generativelanguage.googleapis.com/v1betau  Warm lifestyle photography, soft focus, cinematic mood. Two hands gently clasped together in a supportive handshake — one hand older, one younger — symbolizing mentorship and trust. Warm beige and cream tones dominate: soft natural window light from the left, blurred bokeh background in warm ivory and pale gold. The hands are centered in the lower half of the frame, upper half is beautiful warm-toned soft bokeh light. Color palette: warm cream #F5E6D3, soft gold, pale ivory, warm white. No text, no watermarks, no logos. Shot on Canon EOS R5 with 85mm f/1.4 lens, editorial lifestyle photography. Emotional warmth, human connection, trust and care. Square 1:1 format, 1080x1080.u  <!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<style>
  @font-face {{
    font-family: 'Pretendard';
    src: url('file://{font_dir}/Pretendard-Black.otf') format('opentype');
    font-weight: 900;
  }}
  @font-face {{
    font-family: 'Pretendard';
    src: url('file://{font_dir}/Pretendard-ExtraBold.otf') format('opentype');
    font-weight: 800;
  }}
  @font-face {{
    font-family: 'Pretendard';
    src: url('file://{font_dir}/Pretendard-Bold.otf') format('opentype');
    font-weight: 700;
  }}
  @font-face {{
    font-family: 'Pretendard';
    src: url('file://{font_dir}/Pretendard-SemiBold.otf') format('opentype');
    font-weight: 600;
  }}
  @font-face {{
    font-family: 'Pretendard';
    src: url('file://{font_dir}/Pretendard-Medium.otf') format('opentype');
    font-weight: 500;
  }}
  @font-face {{
    font-family: 'Pretendard';
    src: url('file://{font_dir}/Pretendard-Regular.otf') format('opentype');
    font-weight: 400;
  }}

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

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

  .canvas {{
    position: relative;
    width: 1080px;
    height: 1080px;
    overflow: hidden;
  }}

  /* ── 배경 이미지 ── */
  .bg-image {{
    position: absolute;
    inset: 0;
    background-image: url('{bg_url}');
    background-size: cover;
    background-position: center bottom;
  }}

  /* ── 부드러운 따뜻한 오버레이 그라디언트 ── */
  .warm-overlay {{
    position: absolute;
    inset: 0;
    background: linear-gradient(
      to bottom,
      rgba(245, 230, 211, 0.92) 0%,
      rgba(245, 230, 211, 0.88) 38%,
      rgba(245, 230, 211, 0.60) 58%,
      rgba(245, 230, 211, 0.82) 78%,
      rgba(245, 230, 211, 0.96) 100%
    );
  }}

  /* ── 상단 브랜드 태그 ── */
  .brand-tag {{
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    color: #E8836A;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }}

  /* ── 상단 장식 라인 ── */
  .top-accent-line {{
    position: absolute;
    top: 108px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: #E8836A;
    border-radius: 2px;
  }}

  /* ── 메인 헤드라인 블록 ── */
  .headline-block {{
    position: absolute;
    top: 140px;
    left: 80px;
    right: 80px;
    text-align: center;
  }}

  .headline-main {{
    font-size: 88px;
    font-weight: 800;
    color: #003D82;
    line-height: 1.18;
    letter-spacing: -0.03em;
    word-break: keep-all;
  }}

  .headline-main .em {{
    color: #E8836A;
  }}

  /* ── 구분선 ── */
  .divider {{
    position: absolute;
    top: 424px;
    left: 50%;
    transform: translateX(-50%);
    width: 480px;
    height: 2px;
    background: linear-gradient(
      to right,
      transparent,
      #003D82 20%,
      #003D82 80%,
      transparent
    );
    opacity: 0.35;
  }}

  /* ── 서브 헤드라인 ── */
  .sub-headline {{
    position: absolute;
    top: 450px;
    left: 80px;
    right: 80px;
    text-align: center;
    font-size: 64px;
    font-weight: 700;
    color: #003D82;
    line-height: 1.25;
    letter-spacing: -0.02em;
    word-break: keep-all;
  }}

  /* ── 바디 카피 ── */
  .body-copy {{
    position: absolute;
    top: 576px;
    left: 80px;
    right: 80px;
    text-align: center;
    font-size: 42px;
    font-weight: 500;
    color: #5C4A35;
    letter-spacing: -0.01em;
    line-height: 1.4;
    word-break: keep-all;
  }}

  .body-copy .highlight-amount {{
    font-weight: 800;
    color: #003D82;
  }}

  /* ── 하단 카드 영역 (이미지 위) ── */
  .bottom-card {{
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 400px;
  }}

  /* ── 따뜻한 손 이미지 (배경 하단 포커스) ── */

  /* ── 지원금 배지 ── */
  .support-badge {{
    position: absolute;
    top: 650px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 61, 130, 0.08);
    border: 2px solid rgba(0, 61, 130, 0.20);
    border-radius: 50px;
    padding: 16px 48px;
    white-space: nowrap;
    text-align: center;
  }}

  .support-badge-text {{
    font-size: 40px;
    font-weight: 600;
    color: #5C4A35;
    letter-spacing: -0.01em;
  }}

  .support-badge-text .badge-em {{
    font-weight: 800;
    color: #003D82;
  }}

  /* ── CTA 버튼 ── */
  .cta-wrapper {{
    position: absolute;
    bottom: 96px;
    left: 0;
    right: 0;
    text-align: center;
  }}

  .cta-btn {{
    display: inline-block;
    background: #003D82;
    color: #FFFFFF;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 46px;
    font-weight: 700;
    letter-spacing: -0.01em;
    padding: 22px 72px;
    border-radius: 60px;
    box-shadow: 0 8px 32px rgba(0, 61, 130, 0.30);
  }}

  /* ── 하단 소인 ── */
  .footer-note {{
    position: absolute;
    bottom: 44px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 28px;
    font-weight: 400;
    color: #A08870;
    letter-spacing: 0.01em;
  }}

  /* ── 장식 원형 요소 ── */
  .deco-circle-1 {{
    position: absolute;
    top: -80px;
    right: -80px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(232, 131, 106, 0.12) 0%, transparent 70%);
  }}

  .deco-circle-2 {{
    position: absolute;
    bottom: 200px;
    left: -60px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 61, 130, 0.08) 0%, transparent 70%);
  }}

  /* ── 스파클 도트 ── */
  .sparkle {{
    position: absolute;
    border-radius: 50%;
  }}
  .sparkle-1 {{
    top: 128px;
    left: 120px;
    width: 10px;
    height: 10px;
    background: #E8836A;
    opacity: 0.6;
  }}
  .sparkle-2 {{
    top: 152px;
    right: 140px;
    width: 7px;
    height: 7px;
    background: #003D82;
    opacity: 0.4;
  }}
  .sparkle-3 {{
    top: 420px;
    left: 160px;
    width: 8px;
    height: 8px;
    background: #E8836A;
    opacity: 0.5;
  }}
  .sparkle-4 {{
    top: 430px;
    right: 180px;
    width: 6px;
    height: 6px;
    background: #003D82;
    opacity: 0.35;
  }}

</style>
</head>
<body>
<div class="canvas">

  <!-- 배경 이미지 -->
  <div class="bg-image"></div>

  <!-- 따뜻한 오버레이 -->
  <div class="warm-overlay"></div>

  <!-- 장식 원형 -->
  <div class="deco-circle-1"></div>
  <div class="deco-circle-2"></div>

  <!-- 스파클 도트 -->
  <div class="sparkle sparkle-1"></div>
  <div class="sparkle sparkle-2"></div>
  <div class="sparkle sparkle-3"></div>
  <div class="sparkle sparkle-4"></div>

  <!-- 브랜드 태그 -->
  <div class="brand-tag">T.O.P 사업단</div>

  <!-- 상단 강조 라인 -->
  <div class="top-accent-line"></div>

  <!-- 메인 헤드라인 -->
  <div class="headline-block">
    <div class="headline-main">
      열심히는 하는데,<br>
      소득은 <span class="em">제자리걸음?</span>
    </div>
  </div>

  <!-- 구분선 -->
  <div class="divider"></div>

  <!-- 서브 헤드라인 -->
  <div class="sub-headline">당신의 성장에 힘이 돼줄게요</div>

  <!-- 바디 카피 -->
  <div class="body-copy">
    T.O.P 사업단 &nbsp;|&nbsp; 정착지원금 최대 <span class="highlight-amount">1,000만원</span>
  </div>

  <!-- 지원금 배지 -->
  <div class="support-badge">
    <span class="support-badge-text">
      FA 전환 후 <span class="badge-em">월 평균 수입 2배↑</span>
    </span>
  </div>

  <!-- CTA 버튼 -->
  <div class="cta-wrapper">
    <span class="cta-btn">지금 상담 신청하기 →</span>
  </div>

  <!-- 하단 소인 -->
  <div class="footer-note">인카금융서비스 T.O.P 사업단 · 금융위 등록 보험설계사</div>

</div>
</body>
</html>
c            
         	 t        j                  d      } d|  dd}g d}|D ]  }t         d	| d
}ddt
        igigdddgid}|j                  d      rt         d	| d}dt
        igdddd}t        d| d       	 t        j                  |||d      }|j                  dk(  r^|j                         }|j                  di g      d   j                  d i       j                  dg       D ]Y  }	d!|	v st        j                  |	d!   d"         }
t        j!                  |
       t        d#t         d$t#        |
      d%d&         y' |j                  d(g       D ]V  }d)|v st        j                  |d)         }
t        j!                  |
       t        d*t         d$t#        |
      d%d&         y' |j                  di g      d   j                  d+d,      }t        d-| d       t        d.t%        |      dd/         t        d0|j                   d1|j&                  dd2          y# t        $ r}t        d|        Y d}~yd}~ww xY w# t        $ r}t        d|        Y d}~Sd}~ww xY w)3uB   Gemini AI로 따뜻한 감성 배경 이미지를 생성합니다.z3https://www.googleapis.com/auth/generative-languageu$     [오류] SA 토큰 획득 실패: NFzBearer zapplication/json)AuthorizationzContent-Type)zgemini-2.5-flash-imagezgemini-3.1-flash-image-previewzgemini-3-pro-image-previewzimagen-4.0-generate-001zimagen-4.0-fast-generate-001z/models/z:generateContentpartstextresponseModalitiesTEXTIMAGE)contentsgenerationConfigimagenz:predictprompt   z1:1)sampleCountaspectRatio)	instances
parametersu'     배경 생성 요청 중... (모델: )x   )headersjsontimeoutu     [오류] 연결 실패:    
candidatesr   content
inlineDatadatau     배경 저장 완료:  (, bytes)TpredictionsbytesBase64Encodedu!     배경 저장 완료 (imagen): finishReason?u2     [오류] 이미지 파트 없음 (finishReason: u     응답 미리보기: i  z  [HTTP z] i,  )gcloud_authget_service_account_tokenRuntimeErrorprintGEMINI_API_BASE	BG_PROMPT
startswithrequestspost	Exceptionstatus_coder   getbase64	b64decodeBG_PATHwrite_byteslenstrr	   )sa_tokener   models_to_trymodelurlpayloadrespr   part	img_bytespredreasons                k/home/jay/workspace/.worktrees/task-2116-dev1/tools/ai-image-gen/_backup/gen_concept47_emotional_finance.pygenerate_backgroundrE     s   88A
 #8*-*G
M  3D !%0@A!VY$7#89:!57H I
 H%$%XeWH=C'34./FG
 	7wa@A	==gGSQD
 s"99;D t,Q/Y#Wb!	 
  4' & 0 0l1CF1K LI''	24WIRIq?QQXYZ	  3  '4/ & 0 06J1K LI''	2=gYbYXYHZZabc  t,Q/33NCH  FvhaPQ+CIdsO+<=>HT--.b4C0ABCg3Dj M  4QC89F  	.qc23	s/   H7 I7	I II	I=$I88I=c                   t         j                  t        t              |       }t        dz  }|j                  |d       t        d|        t               5 }|j                  j                         }	 |j                  ddd      }|j                  d	|j                          d
       |j                  d       |j                  t        t              d       |j!                          	 ddd       t        j#                         j$                  }t        dt         d|dd       y# |j!                          w xY w# 1 sw Y   TxY w)u7   HTML 오버레이를 Playwright로 PNG 캡처합니다.)font_dirbg_urlz_concept47_template.htmlzutf-8)encodingu     HTML 템플릿 저장: i8  )widthheight)viewportfile://networkidle)
wait_untili	  png)pathtypeNu     PNG 저장 완료: r    r!   r"   )HTML_TEMPLATEformatr8   FONT_DIR
OUTPUT_DIR
write_textr*   r   chromiumlaunchnew_pagegotoresolvewait_for_timeout
screenshotSAMPLE_PATHclosestatst_size)rH   html_content	html_filepbrowserpagesizes          rD   render_htmlri     s'    ''X ( L 77I8	%i[
12		 	a**##%	##tt-L#MDII	 1 1 345-IP!!$'OO[!1O>MMO	 %%D	!+ba
@A MMO	 	s%   E5A*D.E.E  EEc                 z   t         j                  dd       t        d       t        d       t        d       t        d       t        d       t        d       t               } | st        d       d	}nd
t        j                          }t        d       t        |       t        d       t        j                  t        t               t        dt                t        d       t        dt                t        dt                t        j                         j                  dz  }t        d|dd       y )NT)parentsexist_okz@================================================================u&   컨셉 #47 K.R Award Emotional Financeu>   T.O.P 리크루팅 Meta 광고 — 감정 기반 금융 광고u7   Inspired by Samsung Fire '보험 선물하기' campaignu-   
[1/3] 배경 이미지 생성 (Gemini AI)...uW     [경고] AI 배경 생성 실패. 순수 Warm Beige CSS 배경으로 대체합니다. rM   u2   
[2/3] HTML 오버레이 렌더링 (Playwright)...u   
[3/3] 복사본 생성...u     복사 완료: u   
완료!z  sample.png  : z  named copy  : i   u     파일 크기   : z.0fz KB)rV   mkdirr*   rE   r5   r\   ri   shutilcopy2r_   	COPY_PATHra   rb   )okrH   szs      rD   mainrt     s   TD1	(O	
23	
JK	
CD	(O	
:;		Bgh7??,-.	
?@	
'(
LLi(	i[
)*	I	[M
*+	YK
()					#	#d	*B	 C
,-    __main__)returnbool)rH   r8   rw   None)rw   ry   )__doc__
__future__r   r3   ro   syspathlibr   r.   playwright.sync_apir   rQ   insertr8   __file__parentr'   rV   r5   r_   rq   homerU   r+   r,   rS   rE   ri   rt   __name__ ru   rD   <module>r      s    #   
   / 3tH~,,- .  ef

x
<'<<	499;88D
$ 
 xvL^B2.> zF ru   