
    i8              
          d 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d       ddl
Z
 ed      Zedz  Zedz  Zed	z  Zd
ZdZdefdZdZdZdededededef
dZd Zedk(  r ej4                   e              yy)u   인카다이렉트 M1-1 '정당한 대우' Google 배너 생성기
컨셉 #49 Spikes Trust Protection 스타일 — 기업 로비 배경
- 1200x628 (가로형)
- 1080x1080 (정사각형)
    N)Path)sync_playwrightz&/home/jay/workspace/tools/ai-image-genz-/home/jay/workspace/output/google-ads/bannerszbg_incar_fair.jpgzincar-fair-1200x628.pngzincar-fair-1080x1080.pngz0https://generativelanguage.googleapis.com/v1betaa  Modern corporate headquarters lobby interior, wide floor-to-ceiling glass windows overlooking city skyline, clean polished marble floor with subtle reflections, elegant indirect lighting from ceiling and walls, one professional Korean businessman walking confidently away from camera, business suit, confident upright posture, back view, bright morning natural light streaming through glass, warm golden hour light creating depth and atmosphere, premium corporate aesthetic, photorealistic, high-end Samsung Fire & Marine Insurance level advertisement quality, deep navy and warm gold color tones, spacious modern architecture, no text, no watermarks, no graphics, no charts, no graphs, no handshakes, no meeting rooms, no multiple people, no icons, no illustrations, photo qualityreturnc            
         t        d       	 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}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i g      d   j                  d"d#      }t        d$| d       6t        d%|j                   d&|j                   dd'         ` y# t        $ r}t        d|        Y d}~yd}~ww xY w# t        $ r}t        d|        Y d}~d}~ww xY w)(u;   Gemini SA 토큰으로 배경 이미지를 생성합니다.u     SA 토큰 획득 중...z3https://www.googleapis.com/auth/generative-languageu$     [오류] SA 토큰 획득 실패: NFzBearer zapplication/json)AuthorizationzContent-Type)z)gemini-2.0-flash-preview-image-generationzgemini-3.1-flash-image-previewzgemini-3-pro-image-previewz/models/z:generateContentpartstextresponseModalitiesTEXTIMAGE)contentsgenerationConfigu'     배경 생성 요청 중... (모델: )x   )headersjsontimeoutu     [오류] 연결 실패:    
candidatesr   content
inlineDatadatau     배경 저장 완료:  (,z bytes)TfinishReason?u2     [오류] 이미지 파트 없음 (finishReason: z  [HTTP z] i,  )printgcloud_authget_service_account_token	ExceptionGEMINI_API_BASE	BG_PROMPTrequestspoststatus_coder   getbase64	b64decodeBG_PATHwrite_byteslenr	   )sa_tokener   models_to_trymodelurlpayloadrespr   r   part	img_bytesreasons                ?/home/jay/workspace/output/google-ads/banners/gen_incar_fair.pygenerate_backgroundr7   ,   s   	
%&88A
 #8*-*GM
  D !%0@A!VY$7#89:!57H I
 	7wa@A	==gGSQD s"99;DHH\B40377	2FJJ7TVWE  4' & 0 0l1CF1K LI''	24WIRIq?QQXYZ  XXlRD1!488MFFvhaPQHT--.b4C0ABC1D2 M  4QC89,  	.qc23	s/   F #F6	F3F..F36	G?GGu  <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@500;700;900&display=swap" rel="stylesheet">
<style>
  @font-face {
    font-family: 'Pretendard';
    src: local('Pretendard-Black'); font-weight: 900;
  }
  @font-face {
    font-family: 'Pretendard';
    src: local('Pretendard-Bold'); font-weight: 700;
  }
  @font-face {
    font-family: 'Pretendard';
    src: local('Pretendard-Medium'); font-weight: 500;
  }

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

  body {
    width: 1200px;
    height: 628px;
    overflow: hidden;
    background-color: #0D1E35;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
  }

  .container {
    position: relative;
    width: 1200px;
    height: 628px;
    background-image: url('__BG_PATH__');
    background-size: cover;
    background-position: center right;
  }

  /* 우측 이미지 영역 — 오버레이 없음 (배경 주인공 보호) */
  /* 좌측 60% 네이비→투명 그라데이션 오버레이 */
  .overlay-left {
    position: absolute;
    inset: 0;
    background: linear-gradient(
      90deg,
      rgba(27, 54, 93, 0.96) 0%,
      rgba(27, 54, 93, 0.94) 30%,
      rgba(27, 54, 93, 0.85) 50%,
      rgba(27, 54, 93, 0.40) 68%,
      transparent 80%
    );
  }

  /* 상단 미세 강조 바 */
  .top-accent {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 5px;
    background: linear-gradient(90deg, #C5A572 0%, #D4B87A 40%, transparent 70%);
  }

  /* 텍스트 영역 (좌측 60%) */
  .text-area {
    position: absolute;
    top: 0; left: 0;
    width: 720px;
    height: 628px;
    padding: 52px 60px 52px 60px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* 코스닥 상장사 뱃지 */
  .badge {
    display: inline-flex;
    align-items: center;
    background: #C5A572;
    border-radius: 6px;
    padding: 10px 22px;
    align-self: flex-start;
  }

  .badge-text {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: #1B365D;
    letter-spacing: 0.04em;
  }

  /* 메인 헤드라인 */
  .headline {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 56px;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.25;
    letter-spacing: -0.02em;
  }

  /* 서브카피 */
  .subcopy {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 28px;
    font-weight: 500;
    color: #5B9BD5;
    letter-spacing: 0.02em;
    line-height: 1.4;
  }

  /* CTA 버튼 */
  .cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #C5A572 0%, #D4B87A 100%);
    border-radius: 6px;
    padding: 14px 36px;
    min-width: 220px;
    min-height: 56px;
    align-self: flex-start;
  }

  .cta-text {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: #1A0E00;
    letter-spacing: 0.02em;
  }

  /* 하단 보조 정보 (선택) */
  .bottom-info {
    position: absolute;
    bottom: 24px;
    left: 60px;
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 22px;
    font-weight: 500;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.03em;
  }
</style>
</head>
<body>
<div class="container">
  <div class="overlay-left"></div>
  <div class="top-accent"></div>

  <div class="text-area">
    <!-- 코스닥 상장사 뱃지 -->
    <div class="badge">
      <span class="badge-text">코스닥 상장사</span>
    </div>

    <!-- 메인 헤드라인 -->
    <div class="headline">
      정당한 보상을<br>받고 계신가요?
    </div>

    <!-- 서브카피 -->
    <div class="subcopy">
      투명한 수수료 구조 · 99% 정착률
    </div>

    <!-- CTA 버튼 -->
    <div class="cta-btn">
      <span class="cta-text">조건 확인하기</span>
    </div>
  </div>

  <!-- 하단 보조 -->
  <div class="bottom-info">코스닥 상장 인카금융서비스</div>
</div>
</body>
</html>
u.  <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@500;700;900&display=swap" rel="stylesheet">
<style>
  @font-face {
    font-family: 'Pretendard';
    src: local('Pretendard-Black'); font-weight: 900;
  }
  @font-face {
    font-family: 'Pretendard';
    src: local('Pretendard-Bold'); font-weight: 700;
  }
  @font-face {
    font-family: 'Pretendard';
    src: local('Pretendard-Medium'); font-weight: 500;
  }

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

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

  .container {
    position: relative;
    width: 1080px;
    height: 1080px;
    background-image: url('__BG_PATH__');
    background-size: cover;
    background-position: center;
  }

  /* 반투명 네이비 오버레이 — 전체 (opacity 0.55) */
  .overlay-full {
    position: absolute;
    inset: 0;
    background: rgba(27, 54, 93, 0.56);
  }

  /* 하단 그라데이션 강화 (CTA 가독성) */
  .overlay-bottom {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 320px;
    background: linear-gradient(
      0deg,
      rgba(13, 30, 53, 0.95) 0%,
      rgba(13, 30, 53, 0.70) 50%,
      transparent 100%
    );
  }

  /* 상단 골드 액센트 바 */
  .top-accent {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: linear-gradient(90deg, #C5A572 0%, #D4B87A 100%);
  }

  /* 전체 레이아웃 래퍼 */
  .layout {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 56px 64px 60px 64px;
  }

  /* 코스닥 상장사 뱃지 */
  .badge {
    display: inline-flex;
    align-items: center;
    background: #C5A572;
    border-radius: 6px;
    padding: 12px 28px;
  }

  .badge-text {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 40px;
    font-weight: 700;
    color: #1B365D;
    letter-spacing: 0.04em;
  }

  /* 헤드라인 + 서브카피 블록 */
  .copy-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    text-align: center;
  }

  /* 메인 헤드라인 */
  .headline {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 64px;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.28;
    letter-spacing: -0.02em;
    text-align: center;
  }

  /* 구분선 */
  .divider {
    width: 80px;
    height: 3px;
    background: linear-gradient(90deg, #C5A572, #D4B87A);
    border-radius: 2px;
  }

  /* 서브카피 */
  .subcopy {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 34px;
    font-weight: 500;
    color: #A8C8F0;
    letter-spacing: 0.02em;
    text-align: center;
    line-height: 1.4;
    background: rgba(13, 30, 53, 0.55);
    padding: 14px 28px;
    border-radius: 8px;
  }

  /* CTA 버튼 */
  .cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #C5A572 0%, #D4B87A 100%);
    border-radius: 6px;
    padding: 18px 56px;
    min-width: 300px;
    min-height: 68px;
  }

  .cta-text {
    font-family: 'Pretendard', 'Noto Sans KR', sans-serif;
    font-size: 34px;
    font-weight: 700;
    color: #1A0E00;
    letter-spacing: 0.02em;
  }
</style>
</head>
<body>
<div class="container">
  <div class="overlay-full"></div>
  <div class="overlay-bottom"></div>
  <div class="top-accent"></div>

  <div class="layout">
    <!-- 상단 15%: 코스닥 상장사 뱃지 -->
    <div class="badge">
      <span class="badge-text">코스닥 상장사</span>
    </div>

    <!-- 중앙: 헤드라인 + 서브카피 -->
    <div class="copy-block">
      <div class="headline">
        정당한 보상을<br>받고 계신가요?
      </div>
      <div class="divider"></div>
      <div class="subcopy">
        투명한 수수료 구조 · 99% 정착률
      </div>
    </div>

    <!-- 하단 25%: CTA 버튼 -->
    <div class="cta-btn">
      <span class="cta-text">조건 확인하기</span>
    </div>
  </div>
</div>
</body>
</html>
html_contentoutput_pathwidthheightc                    t         d| d| dz  }t        j                         r*t        j                         j                  dkD  r	dt         nd}| j                  d|      } |j                  | d	       t               5 }|j                  j                         }|j                  ||d
      }|j                  d|        |j                  d       |j                  t        |      d       |j                          ddd       |j                         r1|j                         j                  dz  }	t!        d| d|	dd       yy# 1 sw Y   KxY w)u-   Playwright로 HTML을 PNG로 캡처합니다.overlay_incar_xz.htmlr   zfile:// __BG_PATH__zutf-8)encoding)r:   r;   )viewporti  png)pathtypeNi   u     저장 완료: r   z.0fz KB)TF)
OUTPUT_DIRr)   existsstatst_sizereplace
write_textr   chromiumlaunchnew_pagegotowait_for_timeout
screenshotstrcloser   )
r8   r9   r:   r;   	html_filebg_urlpbrowserpagesize_kbs
             r6   render_html_to_pngrZ     s9   ~eWAfXUCCI$+NN$49O9ORS9Swwi Y[F''v>L8		 a**##%5F)KL		GI;'(d#S-E: ""$,,t3!+bTBC s    BEEc                     t         j                  dd       t        d       t        d       t        d       t        d       t        d       t               } | st        d       t        d       t	        t
        t        d	d
      }t        d       t	        t        t        dd      }t        d       t        d       t        d       t        d|rdnd dt                t        d|rdnd dt                |r|rdS dS )NT)parentsexist_okzA=================================================================u?   인카다이렉트 M1-1 '정당한 대우' Google 배너 생성u;   컨셉 #49 Spikes Trust Protection — 기업 로비 배경u(   
[1/3] Gemini 배경 이미지 생성...uK     [경고] 배경 생성 실패. 딥네이비 배경으로 진행합니다.u-   
[2/3] 1200x628 가로형 배너 렌더링...i  it  u1   
[3/3] 1080x1080 정사각형 배너 렌더링...i8  zB
=================================================================u   결과 요약z  1200x628 : OKFAILu    → z  1080x1080: r      )	rF   mkdirr   r7   rZ   	HTML_1200OUT_1200	HTML_1080OUT_1080)bg_okok1ok2s      r6   mainri     s    TD1	(O	
KL	
GH	(O	
56!E[\	
:;
Y$
<C	
>?
Y$
=C	/	/	(O	M#$62%z
BC	M#$62%z
BC1$1$    __main__)__doc__r'   syspathlibr   r#   playwright.sync_apir   rD   insertr   rF   r)   rc   re   r!   r"   boolr7   rb   rd   rR   intrZ   ri   __name__exit rj   r6   <module>rv      s     
   / ; < AB

*
*1122D0 
&-T -bs	l~	BS t C QT Y] ,%6 zCHHTV rj   