
    i                     n    d Z ddlmZ ddlmZ  ed      Zedz  Zedz  Zedz  Zd Z	e
d	k(  r e	        y
y
)uR   Step 2: Playwright로 HTML 템플릿 렌더링 → sample.png 생성 (concept #19)    )Path)sync_playwrightzC/home/jay/workspace/output/meta-ads/concept-catalog/19-persona-cardztemplate.htmlzbg.pngz
sample.pngc            
         t        dt                t        dt                t        dt                t        j	                         st        dt               t        j	                         st        dt               dt        j                          } t               5 }|j                  j                  g d      }|j                  d	d	d
      }|j                         }dt        j                          }|j                  |dd       |j                  d|  d|  d       |j                  d       |j                  t!        t              dddd	d	d       t        d       |j#                          d d d        t        j%                         j&                  dz  }t        dt         d|dd       y # 1 sw Y   BxY w)Nu   [1] 템플릿: u   [2] 배경:   u   [3] 출력:   u   template.html 없음: u   bg.png 없음: zfile://)z--disable-web-securityz--allow-file-access-from-filesz--no-sandbox)argsi8  )widthheight)viewportnetworkidlei0u  )
wait_untiltimeoutz&() => {
            window.BG_PATH = "u  ";
            // 스크립트 재실행 (window.BG_PATH 설정 후)
            var img = new Image();
            img.crossOrigin = 'anonymous';
            img.onload = function() {
                var iw = img.naturalWidth;
                var ih = img.naturalHeight;
                // 인물 시작: 행 171 (16.7%), 끝: 853 (83.3%)
                // 얼굴 중심부: 약 17~50% 구간을 크롭
                // cropY = ih*0.165 (인물 시작점), cropH = 패널너비*0.95
                var profiles = [
                    { id: 'img1', sx: 0,        sy: 0, sw: iw/3, sh: ih, cropY: ih*0.165 },
                    { id: 'img2', sx: iw/3,     sy: 0, sw: iw/3, sh: ih, cropY: ih*0.165 },
                    { id: 'img3', sx: iw*2/3,   sy: 0, sw: iw/3, sh: ih, cropY: ih*0.165 },
                ];
                profiles.forEach(function(p) {
                    var canvas = document.createElement('canvas');
                    var size = 280;
                    canvas.width = size;
                    canvas.height = size;
                    var ctx = canvas.getContext('2d');
                    var cropY = p.cropY;
                    var cropH = p.sw * 0.95;
                    ctx.drawImage(img, p.sx, cropY, p.sw, cropH, 0, 0, size, size);
                    var el = document.getElementById(p.id);
                    if (el) el.src = canvas.toDataURL('image/jpeg', 0.95);
                });
            };
            img.src = "z";
        }i  pngr   )xyr   r   )pathtypeclipu   [4] 스크린샷 저장 완료i   u   [5] 완료: z (z.0fz KB))printTEMPLATEBGOUTPUTexistsFileNotFoundErrorresolver   chromiumlaunchnew_contextnew_pagegotoevaluatewait_for_timeout
screenshotstrclosestatst_size)bg_file_urlpbrowsercontextpagetemplate_urlsize_kbs          g/home/jay/workspace/.worktrees/task-2116-dev1/output/meta-ads/concept-catalog/19-persona-card/render.pymainr.      s   	OH:
&'	N2$
 	N6(
#$??"8
 CDD99;/" 677BJJL>*K		 8a**## $ 
 %%#t4 & 
 ! !!1!1!3 45		,=%	H 	 *m ,8 $} %; 	B 	d#S[uUYei;jk.0q8t kkm##d*G	L73-t
45w8 8s   $CF>>G__main__N)__doc__pathlibr   playwright.sync_apir   BASEr   r   r   r.   __name__     r-   <module>r7      sQ    X  /QR/!	H_		G6T zF r6   