
    _ii0                         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ZddlmZ ej                  j                  dd        ed      Z ed      ZdZdZd	 Zd
edefdZdedefdZd Zedk(  r e        yy)u   인카다이렉트 M1-3 영업지원 배너 1080x1080 생성 스크립트
hybrid-image 파이프라인: Gemini 배경 + HTML/CSS 오버레이 (Playwright)
    N)Pathz&/home/jay/workspace/tools/ai-image-genzI/home/jay/workspace/output/google-ads/banners/incar-support-1080x1080.pngz#/tmp/incar_support_bg_1080x1080.jpgu  Bright, clean coworking space interior. One person's side profile working on a laptop at a personal desk with two monitors, face not visible. A single coffee cup on the desk. Desktop screen slightly blurred. Warm natural sunlight streaming through large windows. Comfortable, well-organized morning work atmosphere. Soft warm tones — cream, warm white, light wood. Inviting, approachable, professional but not cold. Square 1:1 composition. No money, no rockets, no complex tech equipment, no icons or illustrations. Photo-realistic quality.u  <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;900&display=swap');
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { width: 1080px; height: 1080px; overflow: hidden; font-family: 'Pretendard', 'Noto Sans KR', sans-serif; }
  .container {
    position: relative;
    width: 1080px;
    height: 1080px;
    background-color: #EBF2FF;
  }
  .bg-image {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image: var(--bg-url);
    background-size: cover;
    background-position: center;
  }
  /* 화이트 반투명 오버레이 (텍스트 가독성) — opacity 0.4 */
  .white-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(248, 249, 252, 0.72);
  }
  /* 전체 레이아웃 컨테이너 */
  .layout {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 52px 72px 60px;
  }
  /* 상단 10%: 브랜드 라인 */
  .brand-line {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
  }
  .brand-line-bar {
    flex: 1;
    height: 2px;
    background: linear-gradient(to right, transparent, rgba(43, 87, 151, 0.3));
  }
  .brand-line-bar.right {
    background: linear-gradient(to left, transparent, rgba(43, 87, 151, 0.3));
  }
  .brand-name {
    font-size: 36px;
    font-weight: 600;
    color: #2B5797;
    letter-spacing: 0.05em;
    text-align: center;
    white-space: nowrap;
  }
  /* 헤드라인 영역 (상단~중앙 35%) */
  .headline-area {
    width: 100%;
    text-align: center;
    margin-bottom: 32px;
  }
  .tagline {
    font-size: 28px;
    font-weight: 500;
    color: #5B9BD5;
    letter-spacing: 0.04em;
    margin-bottom: 14px;
  }
  .headline {
    font-size: 56px;
    font-weight: 800;
    color: #1B365D;
    line-height: 1.25;
    letter-spacing: -0.03em;
    word-break: keep-all;
  }
  /* 구분선 */
  .section-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-bottom: 30px;
  }
  .divider-line {
    flex: 1;
    height: 1.5px;
    background: rgba(43, 87, 151, 0.18);
  }
  .divider-diamond {
    width: 8px; height: 8px;
    background: #C5A572;
    transform: rotate(45deg);
  }
  /* 지원 항목 리스트 (중앙 30%) */
  .support-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 38px;
  }
  .support-item {
    display: flex;
    align-items: center;
    gap: 18px;
    background: rgba(255, 255, 255, 0.75);
    border: 1.5px solid rgba(43, 87, 151, 0.12);
    border-radius: 10px;
    padding: 18px 28px;
  }
  .support-icon {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #2B5797;
    flex-shrink: 0;
  }
  .support-text {
    font-size: 40px;
    font-weight: 600;
    color: #1B365D;
    letter-spacing: -0.02em;
    line-height: 1.2;
  }
  .support-text .accent {
    color: #C5A572;
    font-weight: 700;
  }
  /* CTA 버튼 영역 (하단 25%) */
  .cta-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: auto;
  }
  .cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2B5797;
    color: #FFFFFF;
    font-size: 40px;
    font-weight: 700;
    padding: 20px 80px;
    border-radius: 8px;
    letter-spacing: -0.01em;
    min-width: 400px;
  }
  .cta-sub {
    font-size: 28px;
    font-weight: 500;
    color: #5B9BD5;
    letter-spacing: -0.01em;
    text-align: center;
  }
</style>
</head>
<body>
<div class="container">
  <div class="bg-image"></div>
  <div class="white-overlay"></div>
  <div class="layout">
    <!-- 상단 브랜드 라인 -->
    <div class="brand-line">
      <div class="brand-line-bar"></div>
      <span class="brand-name">인카금융서비스</span>
      <div class="brand-line-bar right"></div>
    </div>
    <!-- 헤드라인 -->
    <div class="headline-area">
      <div class="tagline">자본 없이 시작, 상장사가 뒤를 받쳐줍니다</div>
      <div class="headline">무자본창업,<br>인카가 도와드립니다</div>
    </div>
    <!-- 구분선 -->
    <div class="section-divider">
      <div class="divider-line"></div>
      <div class="divider-diamond"></div>
      <div class="divider-line"></div>
    </div>
    <!-- 지원 항목 3줄 -->
    <div class="support-list">
      <div class="support-item">
        <div class="support-icon"></div>
        <span class="support-text">DB 자동화 시스템 제공</span>
      </div>
      <div class="support-item">
        <div class="support-icon"></div>
        <span class="support-text">AI 무상 세팅 지원</span>
      </div>
      <div class="support-item">
        <div class="support-icon"></div>
        <span class="support-text">정착금 <span class="accent">최대 1,000만원</span></span>
      </div>
    </div>
    <!-- CTA -->
    <div class="cta-area">
      <div class="cta-button">무료 상담 신청</div>
      <div class="cta-sub">지금 바로 시작하세요 — 상담은 무료입니다</div>
    </div>
  </div>
</div>
</body>
</html>c                  *    dd l } | j                         S )Nr   )gcloud_authget_access_token)r   s    L/home/jay/workspace/output/google-ads/banners/gen_incar_support_1080x1080.py	get_tokenr      s    ''))    tokenreturnc                    dd l }g d}d}|D ])  }t        d|        | d| d}d|  dd	}d
dt        igigdddgid}	 |j                  |||d      }|j                  dv rt        d| d|j                   d       v|j                          |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 , d }d }t        j                  j!                  |      rBt#        |      j%                         }t'        j(                  d!|      }|r|j+                  d"      }|scd#}t        j                  j!                  |      rBt#        |      j%                         }t'        j(                  d!|      }|r|j+                  d"      }|rPdd l }d$D ]F  }t        d%|        d&| d'| }d(di}d
dt        igigdddgid}	 |j                  |||d      }|j                  dv r>i }	 |j                         }t        d| d|j                   d)t-        |      d d*         |j                          |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 I t        d+       y,# t        $ r}t        d| d|        Y d }~vd }~ww xY w# t        $ r Y "w xY w# t        $ r}t        d| d|        Y d }~d }~ww xY w)-Nr   )gemini-3.1-flash-image-previewgemini-3-flash-previewzgemini-3-pro-image-previewz0https://generativelanguage.googleapis.com/v1betau$     [BG] Gemini 배경 생성 시도: z/models/z:generateContentzBearer zapplication/json)AuthorizationContent-TypepartstextresponseModalitiesIMAGETEXT)contentsgenerationConfigx   )headersjsontimeout)i  i  i  z  [BG] u	    실패 (u   ), 다음 시도...
candidatescontent
inlineDatadatau      [BG] 배경 이미지 저장:  (,z bytes)Tu	    오류: z/home/jay/workspace/.env.keysz2GEMINI_API_KEY\s*=\s*["\']?([A-Za-z0-9_\-]+)["\']?   z/home/jay/workspace/.env)r   r   u     [BG] API key 방식 시도: z8https://generativelanguage.googleapis.com/v1beta/models/z:generateContent?key=r   z):    uD     [BG] Gemini 배경 생성 실패 — 그라데이션 폴백 사용F)requestsprintGEMINI_BG_PROMPTpoststatus_coderaise_for_statusr   getbase64	b64decodeBG_TEMP_PATHwrite_byteslen	Exceptionospathexistsopenreadresearchgroupstr)r
   r$   	model_idsgemini_api_basemodel_idurlr   payloadrespr   r   part	img_byteseapi_key_fileapi_keyr   menv_patherr_datas                       r   generate_bg_imagerH      s   jIHO 4XJ?@ !(3CD&-eW$5GYZ!V-=$>#?@A!57H I
	==gGS=QD?2z43C3C2DDWXY!!#99;DHH\B40377	2FJJ7TVWE  4' & 0 0l1CF1K LI ,,Y7<\N"SQZ^\]L^^efg !6 3LG	ww~~l#|$))+IIKWUggajG-77>>(#8n))+G		OQXYA''!*T 	H28*=>LXJVklsktuC%'9:G%1A(B'CDE%9GV;L$MG}}S'QT}U##6!H#'99; GH:Yt7G7G6HCPXMZ^[^L_K`ab%%'yy{t4Q7;;IrJNNwXZ[! $D#t+$*$4$4T,5G5O$P	$00; @bQTU^Q_`aPbbijk#$+	> 

PQm  	GH:Yqc23	H %   z1#67s|   ?M#AM##AM#6M#?%N%N5*N AN ANN#	N,NN	NNNN	O $N;;O bg_availablec                 N   ddl m} t        }| r4t        j	                         r dt         }|j                  dd| d      }n|j                  dd      }t        j                  dd	d
d      5 }|j                  |       |j                  }d d d        	  |       5 }|j                  j                         }|j                  ddd      }|j                  d d       |j                  d       t        j                   j#                  dd       |j%                  t'        t              d       |j)                          d d d        t+        dt                	 t-        j.                         y# 1 sw Y   xY w# 1 sw Y   >xY w# t-        j.                         w xY w)Nr   )sync_playwrightzfile://z background-image: var(--bg-url);zbackground-image: url('z');zKbackground: linear-gradient(135deg, #EBF2FF 0%, #D6E8FF 50%, #C5D9F5 100%);z.htmlwzutf-8F)suffixmodeencodingdeletei8  )widthheight)viewportnetworkidle)
wait_untili  T)parentsexist_okpng)r2   typeu     [캡처] )playwright.sync_apirK   HTML_TEMPLATEr-   r3   replacetempfileNamedTemporaryFilewritenamechromiumlaunchnew_pagegotowait_for_timeoutOUTPUT_PATHparentmkdir
screenshotr9   closer%   r1   unlink)	rI   rK   htmlbg_uriftmp_htmlpbrowserpages	            r   render_with_playwrightrs   F  ss   3D++-<.)||>5fXSAC ||>ik 
	$	$G#X]	^ bc	66 	!jj'')G##tt-L#MDIIz*}IE!!$'$$TD$AOO[!1O>MMO	 	K=)*
		(! 
	 	 			(s1   .E5F B(FF 5E>F
F F$c            	         t        d       t        j                         } 	 t               }t        |      }t        |      }t        j                         | z
  }|rft        j                         rRt        j                         j                  dz  }t        dt         d|dd	|d
d       t        j                  d       y t        d       t        j                  d       y # t        $ r}t        d| d       d}Y d }~d }~ww xY w)NuD   === 인카다이렉트 M1-3 영업지원 배너 1080x1080 생성 ===u!     [인증] 토큰 획득 실패: u    — 폴백 배경 사용Fi   u   === 완료: r    z.0fz KB, z.1fu   초) ===r   u   === 실패 ===r"   )r%   timer   rH   r0   rs   rf   r3   statst_sizesysexit)startr
   bg_okrB   okelapsedsize_kbs          r   mainr   e  s    	
PQIIKE!%(
 
 	&BiikE!G	k  """$,,t3[MGC=gc](ST  1!4MNOs   C! !	D*D  D__main__)__doc__rx   r1   r+   ru   r6   r]   pathlibr   r2   insertrf   r-   r&   r[   r   r9   boolrH   rs   r   __name__ r	   r   <module>r      s     	   	   ; <^_9: x Up*
QS QT Qh $ >. zF r	   