
    Si                        d Z ddlZddlZddlZddlmZ ddlZ ed      ZdZdZ	dZ
dZd	Zd
efdZdededed
efdZedk(  rD e       Z ed ee       d        eede      Z eede      Z ede         ede        yy)uC   C26 v2 배경 이미지 생성 — aspirational office backgrounds.    N)Pathz7/home/jay/workspace/tools/ai-image-gen/output/v4-hybridzgemini-3.1-flash-image-previewz0https://generativelanguage.googleapis.com/v1betaz3https://www.googleapis.com/auth/generative-languagea	  Modern Korean corporate office with floor-to-ceiling windows showing city skyline at golden hour, warm professional atmosphere, leather chair and wooden desk, premium executive feel, no people, no text, no logos, photorealistic, cinematic lighting, warm amber tonesa  Modern Korean corporate office with floor-to-ceiling windows showing city skyline at golden hour, warm professional atmosphere, leather chair and wooden desk, premium executive feel, no people, no text, no logos, photorealistic, cinematic lighting, warm amber tones, square formatreturnc                  ~    t        j                  ddddt         gddd      } | j                  j	                         S )Ngcloudauthzprint-access-tokenz	--scopes=T)capture_outputtextcheck)
subprocessrunGEMINI_SCOPEstdoutstrip)results    _/home/jay/workspace/.worktrees/task-2117-dev1/tools/ai-image-gen/output/v4-hybrid/gen_c26_v2.py	get_tokenr      s@    ^^	6/9\N1KL$dF ==      tokennamepromptc                    t          dt         d}d|  dd}dd|igigdd	d
gid}t        d| d       t        j                         }t	        j
                  |||d      }|j                          t        j                         |z
  }|j                         }	|	j                  dg       }
|
st        dt        |	      d d        |
d   j                  di       j                  dg       }t        d |D        d       }|5|D cg c]  }d|v s|j                  dd       }}t        d|d d        |d   j                  dd      }t        j                  |d   d         }d|v rdnd}t        d | d!| z  }|j                  |       |j!                         j"                  }t        d| d"|j$                   d#|d$d%|d&d'	       t        |      S c c}w )(Nz/models/z:generateContentzBearer zapplication/json)AuthorizationzContent-Typepartsr	   responseModalitiesIMAGETEXT)contentsgenerationConfig[u   ] 요청 중...   )headersjsontimeout
candidateszNo candidates. Response: i,  r   contentc              3   *   K   | ]  }d |v s|  yw)
inlineDataN ).0ps     r   	<genexpr>zgenerate.<locals>.<genexpr>7   s     =Q<1+<q=s   	 zNo image data. Text parts:    r'   mimeTypez
image/jpegdatajpegz.jpgz.pngbg_c26__v2u
   ] 완료: z (,z bytes, z.1fu   초))GEMINI_API_BASEMODEL_IDprinttimerequestspostraise_for_statusr"   getRuntimeErrorstrnextbase64	b64decode
OUTPUT_DIRwrite_bytesstatst_sizer   )r   r   r   urlr!   payloadstartrespelapsedr/   r$   r   
image_partr*   
text_parts	mime_typeimage_bytesextout_pathsizes                       r   generaterQ   $   s   XhZ/?
@C")% 1CUVG 01231GV3DEG 
AdV?
#$IIKE==gGSIDiikE!G99;D,+J6s4y#6GHIIqMi,00"=E=%=tDJ16FA&A+aeeFB'F
F8BQ8HIJJ<(,,ZFI"":l#;F#CDKi'&VCgdV3se44H%==?""D	AdV:hmm_BtAhhwsm4
PQx= Gs   	GG__main__zToken acquired (z chars)	landscapesquarez
Landscape: zSquare:    )__doc__r?   r   r7   pathlibr   r8   rA   r5   r4   r   LANDSCAPE_PROMPTSQUARE_PROMPTr=   r   rQ   __name__r   r6   lenlpsqr(   r   r   <module>r]      s    I     KL
+DDY h !3 !C s C C D zKE	SZL
01	%&6	7B	%=	1B	M"
	Kt
 r   