
    DiI                    T   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ej                  j                  d ee             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g dZddZddZddZddZddZedk(  r e        yy)u  GA 배너 M2-3 'GA × 영업지원' 세트 생성 — 하이브리드 방식 (Gemini 배경 + Playwright 오버레이).

산출물:
  /home/jay/workspace/output/google-ads/banners/m2/m2-3-1200x628.png
  /home/jay/workspace/output/google-ads/banners/m2/m2-3-1080x1080.png
    )annotationsN)Path)sync_playwrightz&/home/jay/workspace/tools/ai-image-genz0/home/jay/workspace/output/google-ads/banners/m2zm2-3-bg.jpgzm2-3-1200x628.pngzm2-3-1080x1080.pngz.local/share/fonts/Pretendardu>  Photographic scene of a small, bright team working space in Seoul. Medium shot, eye-level angle from the side. A round table with 2-3 young professionals (20s-30s) seated, one laptop open in the center. They are looking at the screen together in a collaborative, relaxed posture — not formal. No one is presenting or leading; it feels like a peer discussion. Natural light from a large window on the left. White and light wood interior. A small succulent plant in the corner of the table. People are in business casual — light shirts, no ties. Faces are angled away or partially obscured by looking at the screen. Warm, inviting, supportive atmosphere — feels like a good team to join. Background: clean white wall, one simple plant on a shelf. 사진 품질, 실사, 소규모 협업 팀 장면, 밝고 따뜻한 분위기.z0https://generativelanguage.googleapis.com/v1betaz3https://www.googleapis.com/auth/generative-language)z)gemini-2.0-flash-preview-image-generationzgemini-3-pro-image-previewzgemini-3.1-flash-image-previewc                    t        d       t        j                  d      } | rJt        d       t        D ]5  }t        d|        	 t         d| d|  }ddt
        igigd	d
dgid}t        j                  ||d      }|j                  dk(  r|j                         }|j                  dg       }|r|d   j                  di       j                  dg       }|D ]b  }d|v s|d   d   }	t        j                  |	      }
t        j                  |
       t        dt         dt        |
      dd       t        c c S  t        d| d|j                   d|j                   dd         8 t        d       	 t        j$                  t&              }t        D ]   }	 t         d| d}d | d!d"}ddt
        igigd	d
dgid}t        j                  |||d#      }|j                  dk(  r|j                         }|j                  dg       }|r~|d   j                  di       j                  dg       }|D ]T  }d|v s|d   d   }	t        j                  |	      }
t        j                  |
       t        d$t                t        c c S  t        d%| d|j                   d|j                   dd         # 	 t)        d'      # t"        $ r}t        d| d|        Y d}~d}~ww xY w# t"        $ r}t        d%| d|        Y d}~xd}~ww xY w# t"        $ r"}t        d&|        Y d}~t)        d'      d}~ww xY w)(u?   Gemini API로 배경 이미지를 생성하고 저장합니다.u(   [배경 생성] Gemini API 호출 중...GEMINI_API_KEYu     인증: API 키 사용u     모델 시도: z/models/z:generateContent?key=partstextresponseModalitiesIMAGETEXT)contentsgenerationConfigx   )jsontimeout   
candidatesr   content
inlineDatadatau     배경 생성 완료:  (, bytes)  u    응답 z: Nu	    오류: u%     API 키 실패, SA 토큰 시도...z:generateContentzBearer zapplication/json)AuthorizationzContent-Type)headersr   r   u     배경 생성 완료 (SA): z  SA/u     SA 토큰 오류: uZ   모든 Gemini API 인증 방법 실패 — 배경 이미지를 생성할 수 없습니다.)printgcloud_authget_api_keyMODELS_TO_TRYGEMINI_API_BASEGEMINI_BG_PROMPTrequestspoststatus_coder   getbase64	b64decodeBG_IMAGE_PATHwrite_byteslenr	   	Exceptionget_service_account_tokenGEMINI_SCOPERuntimeError)api_keymodelurlpayloadrespr   r   r   partimg_b64	img_bytesetokenr   s                 </home/jay/workspace/output/google-ads/banners/m2/gen_m2_3.pygenerate_backgroundr;   ?   s   	
45 %%&67G()" 	0E%eW-.0()%8MgYW")V5E,F+G!H I)=?P(Q  }}SwD##s*99;D!%,!;J! *1 1 1)R @ D DWb Q$) 5D+t3*.|*<V*D,2,<,<W,E	 - 9 9) D %(@rRUV_R`abQccj&k l'4 45 5'$*:*:);2diio=NOP+	04 

12*55lC" 	3E3()%8HI.5eW,=Oab")V5E,F+G!H I)=?P(Q  }}S'QTU##s*99;D!%,!;J! *1 1 1)R @ D DWb Q$) 5D+t3*.|*<V*D,2,<,<W,E	 - 9 9) D %(Em_&U V'4 45 eWHT-=-=,>b4C@QRS+	36 s
ttE  05'1#.//0:  3eWIaS1223 *$QC())
s
tt*s|   BK	#AK	?,K	:#L B!K1 AK1L ,K1:L 		K.K))K.1	L:LL LL 	M"L??Mc                F    dt          dt          dt          dt          d|  dS )N<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
  @font-face {
    font-family: 'Pretendard';
    src: url('file:///Pretendard-Bold.otf') format('opentype');
    font-weight: 700;
  }
  @font-face {
    font-family: 'Pretendard';
    src: url('file:///Pretendard-SemiBold.otf') format('opentype');
    font-weight: 600;
  }
  @font-face {
    font-family: 'Pretendard';
    src: url('file:///Pretendard-Medium.otf') format('opentype');
    font-weight: 500;
  }
  @font-face {
    font-family: 'Pretendard';
    src: url('file://uZ  /Pretendard-Regular.otf') format('opentype');
    font-weight: 400;
  }

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

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

  .canvas {
    width: 1200px;
    height: 628px;
    position: relative;
    overflow: hidden;
    border-radius: 0;
  }

  /* 전체 배경 이미지 (우측에 팀 협업 장면 표시) */
  .bg-full {
    position: absolute;
    top: 0;
    left: 0;
    width: 1200px;
    height: 628px;
    background-image: url('file://u	  ');
    background-size: cover;
    background-position: center center;
  }

  /* 좌측 720px 라이트 그린 소프트 패널 (opacity 0.80) */
  .overlay-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 720px;
    height: 628px;
    background: linear-gradient(
      to right,
      rgba(232, 245, 233, 0.80) 0%,
      rgba(232, 245, 233, 0.80) 75%,
      rgba(232, 245, 233, 0.40) 88%,
      rgba(232, 245, 233, 0.0) 100%
    );
  }

  /* 텍스트 영역 — 좌측 720px, 패딩 좌 60px 상 52px */
  .text-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 720px;
    height: 628px;
    padding-left: 60px;
    padding-top: 52px;
    padding-right: 40px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
  }

  /* 헤드라인: 58px Bold #2E7D32, line-height 1.2 */
  .headline {
    font-size: 58px;
    font-weight: 700;
    color: #2E7D32;
    line-height: 1.2;
    letter-spacing: -1px;
    margin-top: 20px;
    white-space: pre-line;
  }

  /* 지원 항목(서브카피): 44px Medium #546E7A, gap 20px */
  .subcopy {
    font-size: 44px;
    font-weight: 500;
    color: #546E7A;
    line-height: 1.3;
    margin-top: 20px;
  }

  /* 보조 정보: 40px Medium #2E7D32, gap 16px */
  .aux-info {
    font-size: 40px;
    font-weight: 500;
    color: #2E7D32;
    line-height: 1.3;
    margin-top: 16px;
  }

  /* CTA: y:530px 고정, 높이 56px, 너비 400px, round 4px */
  .cta-btn {
    position: absolute;
    top: 530px;
    left: 60px;
    width: 400px;
    height: 56px;
    background: #00695C;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    color: #FFFFFF;
    white-space: nowrap;
    letter-spacing: -0.5px;
    padding: 0 16px;
  }
</style>
</head>
<body>
<div class="canvas">

  <!-- 전체 배경 -->
  <div class="bg-full"></div>

  <!-- 좌측 라이트 그린 소프트 패널 오버레이 -->
  <div class="overlay-left"></div>

  <!-- 텍스트 영역 -->
  <div class="text-area">
    <div class="headline">영업이 힘들다면,&#10;시스템 있는 GA로</div>
    <div class="subcopy">DB 제공  |  교육  |  함께 성장</div>
    <div class="aux-info">혼자 뛰지 않는 보험영업 구조</div>
  </div>

  <!-- CTA 버튼 (y:530px 고정) -->
  <div class="cta-btn">영업지원 GA 알아보기 →</div>

</div>
</body>
</html>FONT_DIRbg_image_paths    r:   build_html_1200x628rE      sR     Z  
 Z  
 Z  
 Z   #@ $1/ l2mb b    c                F    dt          dt          dt          dt          d|  dS )Nr=   r>   r?   r@   u]  /Pretendard-Regular.otf') format('opentype');
    font-weight: 400;
  }

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

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

  .canvas {
    width: 1080px;
    height: 1080px;
    position: relative;
    overflow: hidden;
    border-radius: 0;
  }

  /* 전체 배경 이미지 (팀 협업 장면이 보여야 함) */
  .bg-full {
    position: absolute;
    top: 0;
    left: 0;
    width: 1080px;
    height: 1080px;
    background-image: url('file://u  ');
    background-size: cover;
    background-position: center center;
  }

  /* 라이트 그린 전체 오버레이 opacity 0.25 (배경 협업 장면이 더 보임) */
  .overlay-full {
    position: absolute;
    top: 0;
    left: 0;
    width: 1080px;
    height: 1080px;
    background: rgba(232, 245, 233, 0.35);
  }

  /* 반투명 화이트 텍스트 패널 */
  .text-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    padding: 60px 48px;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 12px;
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  /* 콘텐츠 영역: 패딩 좌우 72px, 상 88px, 하 80px, 중앙 정렬 */
  .content-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 1080px;
    height: 1080px;
    padding: 88px 72px 80px 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
  }

  /* 헤드라인: 60px Bold #2E7D32 (포레스트 그린), 중앙 정렬, line-height 1.2 */
  .headline {
    font-size: 60px;
    font-weight: 700;
    color: #2E7D32;
    line-height: 1.2;
    letter-spacing: -1.5px;
    text-align: center;
    white-space: pre-line;
    text-shadow: 0 1px 3px rgba(232, 245, 233, 0.8);
  }

  /* 지원 항목(서브카피): 44px Medium #546E7A (쿨 그레이), 중앙 정렬, gap 24px */
  .subcopy {
    font-size: 44px;
    font-weight: 500;
    color: #546E7A;
    line-height: 1.3;
    text-align: center;
    margin-top: 24px;
    text-shadow: 0 1px 3px rgba(232, 245, 233, 0.8);
  }

  /* 보조 정보: 40px Medium #2E7D32 (포레스트 그린), 중앙 정렬, gap 16px */
  .aux-info {
    font-size: 40px;
    font-weight: 500;
    color: #2E7D32;
    line-height: 1.3;
    text-align: center;
    margin-top: 16px;
    text-shadow: 0 1px 3px rgba(232, 245, 233, 0.8);
  }

  /* CTA: 중앙, 높이 68px, 너비 380px, round 4px, gap 36px */
  .cta-btn {
    margin-top: 36px;
    width: 380px;
    height: 68px;
    background: #00695C;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    font-weight: 700;
    color: #FFFFFF;
    white-space: nowrap;
    letter-spacing: -0.5px;
    text-shadow: none;
  }
</style>
</head>
<body>
<div class="canvas">

  <!-- 전체 배경 -->
  <div class="bg-full"></div>

  <!-- 라이트 그린 전체 오버레이 (opacity 0.25, 배경 협업 장면 더 보임) -->
  <div class="overlay-full"></div>

  <!-- 반투명 화이트 텍스트 패널 (배경과 텍스트 분리) -->
  <div class="text-panel">
    <div class="headline">영업이 힘들다면,&#10;시스템 있는 GA로</div>
    <div class="subcopy">DB 제공  |  교육  |  함께 성장</div>
    <div class="aux-info">혼자 뛰지 않는 보험영업 구조</div>
    <div class="cta-btn">영업지원 GA 알아보기 →</div>
  </div>

</div>
</body>
</html>rA   rC   s    r:   build_html_1080x1080rH   >  sR     Z  
 Z  
 Z  
 Z   #@ $1/ w2mm mrF   c                b   |j                   d|j                   dz  }|j                  | d       t        d|        t	               5 }|j
                  j                         }	 |j                  ||d      }|j                  d|j                          d	
       |j                  d       |j                  t        |      d       t        d| d|j                         j                  dd       |j                          	 d d d        y # |j                          w xY w# 1 sw Y   y xY w)N_tmp_z.htmlzutf-8)encodingu     HTML 템플릿 저장: )widthheight)viewportzfile://networkidle)
wait_untili	  png)pathtypeu     캡처 완료: r   r   r   )parentstem
write_textr   r   chromiumlaunchnew_pagegotoresolvewait_for_timeout
screenshotstrstatst_sizeclose)html_contentoutput_pathrL   rM   	html_filepbrowserpages           r:   capturerh     s   ""u[-=-=,>e%DDI8	%i[
12		 	a**##%	##u-O#PDII	 1 1 345-IP!!$'OO[!1O>%k]"[5E5E5G5O5OPQ4RRYZ[MMO	 	 MMO	 	s%   	D%%BD6D%D""D%%D.c                 n   t         j                  dd       t        d       t        d       t        d       t        j                         } t	               }t        dt        j                         | z
  dd       t        |j                               }t        d       t        j                         }t        |      }t        |t        d	d
       t        dt        j                         |z
  dd       t        d       t        j                         }t        |      }t        |t        dd       t        dt        j                         |z
  dd       t        d       t        d       t        dt                t        dt                t        dt        j                         | z
  dd       y )NT)parentsexist_okz<============================================================uD   GA 배너 M2-3 'GA × 영업지원' 하이브리드 이미지 생성u     배경 생성 소요: z.1fu   초
u)   [1/2] 1200x628 가로형 배너 생성...i  it  u
     소요: u-   [2/2] 1080x1080 정사각형 배너 생성...i8  u   완료!r   u     총 소요: u   초)
OUTPUT_DIRmkdirr   timer;   r^   r[   rE   rh   OUTPUT_1200x628rH   OUTPUT_1080x1080)t0bg_pathbg_strt1	html_widet2html_sqs          r:   mainrx     sX   TD1	(O	
PQ	(O 
B!#G	$TYY[^C$8
>?"#F 

56	B#F+IIc2	Jtyy{2~c*%
01 

9:	B"6*GG%tT2	Jtyy{2~c*%
01	(O	)	B
 !	B 
!"	N499;r>#.c
23rF   __main__)returnr   )rD   r^   rz   r^   )
rb   r^   rc   r   rL   intrM   r{   rz   None)rz   r|   ) __doc__
__future__r   r'   sysrn   pathlibr   r#   playwright.sync_apir   TOOL_DIRrR   insertr^   r   rl   r)   ro   rp   homerB   r"   r!   r.   r    r;   rE   rH   rh   rx   __name__ rF   r:   <module>r      s    #  
    /
 89 3x= ! DE
]*22 44 499;88V  EDAu^c`nh(4D zF rF   