
    ip>                       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
 ddlmZmZ ej                  j                  d e ee      j$                               ddlZdZdZd	Zd
ZdZdZdZdZdZdZedz  Zedz  Zedz  Z edz  Z!edz  Z"edz  Z#dZ$dZ%dZ&d!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 영업지원 세트 생성 스크립트.

Gemini 배경 + HTML/CSS 오버레이 하이브리드 방식.
- 1200x628 (가로형)
- 1080x1080 (정사각형)
    )annotationsN)Path)sync_playwright)WORKSPACE_ROOTFONT_DIR                ,   6   g{Gz?g      ?   zoutput/google-ads/bannersz_ga_support_bg.jpgz_ga_support_1200x628.htmlz_ga_support_1080x1080.htmlzga-support-1200x628.pngzga-support-1080x1080.pnga  A bright and warm small educational space scene. 2 to 3 people sit around a round table looking at laptops and having a natural conversation. Natural light streaming through windows, indoor green plants, clean white modern interior. Collaborative and communicative comfortable work environment. Mid-range to distant shot of people, not too close. Photo realistic quality, warm tones, bright and airy atmosphere. High resolution photograph scene.z0https://generativelanguage.googleapis.com/v1betaz3https://www.googleapis.com/auth/generative-languagec            	        t        d       t        j                  t              } t        dt	        |        d       g d}|D ]}  }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v rt        d|j                   d       {|j                          |j                         }|j                  dg       }	|	st        d       |	d   j                  di       j                  dg       }
t        d |
D        d      }|t        d       |d   j                  d d!      }t        j                   |d   d"         }d#|v rd$nd%}t"        j%                  |      }|j'                  |       t        d&| d't	        |      d(d)       |c S  t)        d*      # t        j                  $ r}t        d| d       Y d}~d}~ww xY w)+u&   Gemini API로 배경 이미지 생성.u(   [배경] Gemini API 토큰 획득 중...u   [배경] 토큰 획득 완료 (z chars))z)gemini-2.0-flash-preview-image-generationzgemini-3-pro-image-previewzimagen-3.0-generate-001u   [배경] 모델 시도: z/models/z:generateContentzBearer zapplication/json)AuthorizationzContent-TypepartstextresponseModalitiesIMAGETEXT)contentsgenerationConfigx   )headersjsontimeout)i  i       → u'    접근 불가, 다음 모델 시도...u     → HTTP 오류: u   , 다음 모델 시도...N
candidatesu0     → candidates 없음, 다음 모델 시도...r   contentc              3  *   K   | ]  }d |v s|  yw)
inlineDataN ).0ps     Z/home/jay/workspace/.worktrees/task-2116-dev1/tools/ai-image-gen/gen_ga_support_banners.py	<genexpr>z&generate_background.<locals>.<genexpr>f   s     A|q/@1As   	u6     → 이미지 파트 없음, 다음 모델 시도...r!   mimeTypez
image/jpegdatajpegz.jpgz.pngu   [배경] 저장 완료:  (, bytes)u"   모든 Gemini 모델 시도 실패)printgcloud_authget_service_account_tokenGEMINI_SCOPElenGEMINI_API_BASEGEMINI_PROMPTrequestspoststatus_coderaise_for_status	HTTPErrorr   getnextbase64	b64decodeBG_PATHwith_suffixwrite_bytesRuntimeError)tokenmodels_to_trymodel_idurlr   payloadresper(   r   r   
image_partmime	img_bytesextbg_paths                   r%   generate_backgroundrM   =   s*   	
4511,?E	+CJ<w
?@M " ((
34 !(3CD&ug..

 "V]$;#<=>!57H I

	==gGSQD:-t//00WXY!!#
 yy{XXlB/
DF1!!)R044WbAAeA4H
JL,'++JE$$Z%=f%EF	$fF%%c*I&(	C	N13EWMNQ(T ;
<<1 !! 	's*CDE	s   =A G>GG<"G77G<c                     g d} g }| D ]*  \  }}t         d| dz  }|j                  d| d| d       , dj                  |      S )u$   Pretendard 폰트 @font-face 정의.))Boldi  )SemiBoldiX  )Mediumi  )Regulari  )	ExtraBoldi   )Blacki  zPretendard-z.otfzC  @font-face {
    font-family: 'Pretendard';
    src: url('file://z(') format('opentype');
    font-weight: z;
  }
)r   appendjoin)weightslinesnamewfpaths        r%   
font_facesr]   z   sq    G E 	a[d33 W   			 99U    c                |    t               }d| d|  dt         dt         dt         dt         dt         dt
         d	S )
u   1200x628 가로형 배너 HTML.=<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
u  

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

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

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

  /* 우측 40%: Gemini 배경 이미지 */
  .bg-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 520px;
    height: 628px;
    background-image: url('file://u  ');
    background-size: cover;
    background-position: center;
  }

  /* 우측 이미지→좌측 페이드 그라데이션 */
  .bg-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 160px;
    background: linear-gradient(to right, #F7F9F7 0%, rgba(247,249,247,0) 100%);
    z-index: 1;
  }

  /* 좌측 60%: 텍스트 패널 */
  .text-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 720px;
    height: 628px;
    background: linear-gradient(135deg, #F7F9F7 0%, #EEF5EE 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 72px;
    z-index: 2;
  }

  /* 상단 태그 */
  .tag {
    display: inline-block;
    background: #66BB6A;
    color: #FFFFFF;
    font-size: u   px;
    font-weight: 700;
    padding: 8px 22px;
    border-radius: 6px;
    margin-bottom: 28px;
    width: fit-content;
    letter-spacing: -0.3px;
  }

  /* 헤드라인 */
  .headline {
    font-size: z?px;
    font-weight: 700;
    color: #1A1A1A;
    line-height: u   ;
    letter-spacing: -1px;
    margin-bottom: 20px;
  }

  .headline .highlight {
    color: #00897B;
  }

  /* 서브 카피 */
  .sub-copy {
    font-size: ztpx;
    font-weight: 500;
    color: #555555;
    margin-bottom: 40px;
    letter-spacing: -0.3px;
    line-height: u   ;
  }

  .sub-copy .dot-sep {
    color: #66BB6A;
    font-weight: 700;
    margin: 0 8px;
  }

  /* CTA 버튼 */
  .cta-btn {
    display: inline-block;
    background: #00897B;
    color: #FFFFFF;
    font-size: u  px;
    font-weight: 700;
    padding: 18px 40px;
    border-radius: 8px;
    letter-spacing: -0.5px;
    width: fit-content;
  }

  .cta-btn .arrow {
    margin-left: 8px;
    opacity: 0.9;
  }

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

  <!-- 우측 배경 이미지 -->
  <div class="bg-panel"></div>

  <!-- 좌측 텍스트 패널 -->
  <div class="text-panel">
    <div class="tag">영업지원 GA</div>
    <div class="headline">영업이 힘들다면,<br><span class="highlight">시스템 있는 GA</span></div>
    <div class="sub-copy">
      DB 제공<span class="dot-sep">|</span>교육<span class="dot-sep">|</span>함께 성장
    </div>
    <div class="cta-btn">영업지원 GA 알아보기 <span class="arrow">→</span></div>
  </div>

</div>
</body>
</html>)r]   
_SIZE_26PX
_SIZE_44PX_LH_1_28_LH_1_5
_SIZE_28PXrL   ffs     r%   build_html_1200rh      s|    	B
  #4 $+) #,F |  |    | 
   | !]O Or^   c                    t               }d| d|  dt         dt         dt         dt         dt         dt
         d	t         d
S )u#   1080x1080 정사각형 배너 HTML.r`   u  

  * { 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;
  }

  /* 전체 배경 */
  .bg-full {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('file://u  ');
    background-size: cover;
    background-position: center;
    z-index: 0;
  }

  /* 라이트 그린 반투명 오버레이 (opacity 0.30) */
  .green-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(102, 187, 106, 0.30);
    z-index: 1;
  }

  /* 하단 그라데이션: 텍스트 가독성 확보 */
  .bottom-gradient {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 600px;
    background: linear-gradient(
      to bottom,
      rgba(245,249,245,0) 0%,
      rgba(245,249,245,0.75) 40%,
      rgba(245,249,245,0.95) 70%,
      #F5F9F5 100%
    );
    z-index: 2;
  }

  /* 콘텐츠 레이어 */
  .content {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 80px;
  }

  /* 상단 태그 (배경 이미지 위 간격) */
  .tag {
    display: inline-block;
    background: #66BB6A;
    color: #FFFFFF;
    font-size: u   px;
    font-weight: 700;
    padding: 10px 28px;
    border-radius: 8px;
    margin-bottom: 32px;
    letter-spacing: -0.3px;
  }

  /* 헤드라인 */
  .headline {
    font-size: zWpx;
    font-weight: 700;
    color: #1A1A1A;
    text-align: center;
    line-height: u  ;
    letter-spacing: -1.5px;
    margin-bottom: 28px;
    padding: 0 60px;
  }

  .headline .highlight {
    color: #00897B;
  }

  /* 지원 항목 3줄 */
  .support-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 44px;
  }

  .support-item {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: a  px;
    font-weight: 500;
    color: #333333;
  }

  .support-icon {
    width: 36px;
    height: 36px;
    background: #66BB6A;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: z?px;
    font-weight: 700;
    flex-shrink: 0;
    line-height: u   ;
    padding-top: 2px;
  }

  /* CTA 버튼 */
  .cta-btn {
    display: inline-block;
    background: #00897B;
    color: #FFFFFF;
    font-size: u  px;
    font-weight: 700;
    padding: 22px 56px;
    border-radius: 8px;
    letter-spacing: -0.5px;
  }

  .cta-btn .arrow {
    margin-left: 10px;
  }

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

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

  <!-- 라이트 그린 오버레이 -->
  <div class="green-overlay"></div>

  <!-- 하단 그라데이션 -->
  <div class="bottom-gradient"></div>

  <!-- 콘텐츠 -->
  <div class="content">
    <div class="tag">영업지원 GA</div>
    <div class="headline">영업이 힘들다면,<br><span class="highlight">시스템 있는 GA</span></div>

    <div class="support-items">
      <div class="support-item">
        <div class="support-icon">✓</div>
        <span>DB 제공 — 영업할 고객, 미리 준비</span>
      </div>
      <div class="support-item">
        <div class="support-icon">✓</div>
        <span>교육 — 입사부터 성장까지 지원</span>
      </div>
      <div class="support-item">
        <div class="support-icon">✓</div>
        <span>함께 성장 — 팀과 함께하는 커리어</span>
      </div>
    </div>

    <div class="cta-btn">영업지원 GA 알아보기 <span class="arrow">→</span></div>
  </div>

</div>
</body>
</html>)r]   
_SIZE_30PX
_SIZE_54PXrc   
_SIZE_22PX_LH_1
_SIZE_32PXrf   s     r%   build_html_1080ro   $  s    	B
  #, $+) .,\ | 
 |   . |  |   	 | 2Qz zr^   c                   t               5 }|j                  j                         }	 |j                  ||d      }|j	                  d| j                          d       |j                  d       |j                  j                  dd       |j                  t        |      d	
       |j                          	 ddd       y# |j                          w xY w# 1 sw Y   yxY w)u!   Playwright로 HTML 배너 캡처.)widthheight)viewportzfile://networkidle)
wait_untili	  Tparentsexist_okpng)pathtypeN)r   chromiumlaunchnew_pagegotoresolvewait_for_timeoutparentmkdir
screenshotstrclose)	html_pathoutput_pathrq   rr   r$   browserpages          r%   capture_bannerr     s    		 
a**##%	##u-O#PDII	 1 1 345-IP!!$'$$TD$AOO[!1O>MMO
 
 MMO
 
s#   CBC*CCCC"c                    t         j                  dd       t        d       t        d       t        d       t        j                         } t	               }t        d       t        t        |j                                     }t        j                  |d       t        dt                t        t        |j                                     }t        j                  |d       t        dt                t        d	       t        t        t        d
d       t        j                         j                  }t        dt         d|dd       t        d       t        t        t         dd       t         j                         j                  }t        dt          d|dd       t        j                         | z
  }t        d       t        d|dd       t        dt                t        dt                 t        d       y )NTrv   z<============================================================u$   GA 영업지원 배너 생성 시작u   
[HTML] 템플릿 빌드 중...zutf-8)encodingr   u   
[캡처] 1200x628 배너...i  it  r*   r+   r,   u   
[캡처] 1080x1080 배너...i8  z=
============================================================u   완료! 총 소요 시간: z.1fu   초u   산출물 1: u   산출물 2: )
OUTPUT_DIRr   r-   timerM   rh   r   r   	HTML_1200
write_textro   	HTML_1080r   OUT_1200statst_sizeOUT_1080)t0rL   	html_1200	html_1080	size_1200	size_1080elapseds          r%   mainr     s   TD1 
(O	
01	(O	B!#G 

,-GOO$5 67IW5	F9+
GOO$5 67IW5	F9+
 

)*9hc2''I	F8*Bym7
34	
*+9hd3''I	F8*Bym7
34iikBG	/	'}C
89	M(
$%	M(
$%	(Or^   __main__)returnr   )r   r   )rL   r   r   r   )
r   r   r   r   rq   intrr   r   r   None)r   r   ).__doc__
__future__r   r;   sysr   pathlibr   r4   playwright.sync_apir   
gen_configr   r   rz   insertr   __file__r   r.   rl   ra   re   rj   rn   rb   rk   rc   rd   rm   r   r=   r   r   r   r   r3   r2   r0   rM   r]   rh   ro   r   r   __name__r"   r^   r%   <module>r      s   #  
    / / 3tH~,,- . 







	
 99

+
+44	55	1122(  ED6=z*Rj}H&%P zF r^   