
    +j                     ~   % S SK r S SKJr  S SKJr  S SKJrJr   " S S\\5      r	\	R                  S\	R                  S\	R                  S	\	R                  S
\	R                  S\	R                  S\	R                   S\	R"                  S0r\\	\\\4   4   \S'    " S S\R.                  5      r " S S\5      rS\4S jrg)    N)Enum)override)ComfyExtensionioc                   4    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rg)AspectRatio   z1:1 (Square)z2:3 (Portrait Photo)z3:2 (Photo)z3:4 (Portrait Standard)z4:3 (Standard)z9:16 (Portrait Widescreen)z16:9 (Widescreen)z21:9 (Ultrawide) N)__name__
__module____qualname____firstlineno__SQUAREPHOTO_VPHOTO_H
STANDARD_V
STANDARD_HWIDESCREEN_VWIDESCREEN_HULTRAWIDE_H__static_attributes__r
       =/home/wildlama/comfy/ComfyUI/comfy_extras/nodes_resolution.pyr   r      s*    F$GG*J!J/L&L$Kr   r   )   r   )      )r   r   )r      )r   r   )	      )r   r   )   r   ASPECT_RATIOSc            	       `    \ rS rSrSr\S 5       r\S\S\S\	S\
R                  4S j5       rS	rg
)ResolutionSelector   zBCalculate width and height from aspect ratio and megapixel target.c                    [         R                  " SSSS[         R                  R                  S[        [        R
                  SS9[         R                  R                  SS	S
SS
SS9[         R                  R                  SSSSSSSS9/[         R                  R                  SSS9[         R                  R                  SSS9/S9$ )Nr#   zResolution Selector	utilitieszwCalculate width and height from aspect ratio and megapixel target. Useful for setting up Empty Latent Image dimensions.aspect_ratioz+The aspect ratio for the output dimensions.)optionsdefaulttooltip
megapixelsg      ?g?g      0@u9   Target total megapixels. 1.0 MP ≈ 1024x1024 for square.)r)   minmaxstepr*   multiple      r   zANearest multiple of the result to set the selected resolution to.T)idr)   r,   r-   r.   r*   advancedwidthz?Calculated width in pixels multiplied by the selected multiple.)r*   heightz@Calculated height in pixels multiplied by the selected multiple.)node_iddisplay_namecategorydescriptioninputsoutputs)	r   SchemaComboInputr   r   FloatIntOutput)clss    r   define_schema ResolutionSelector.define_schema!   s    yy(.  R"''..I	    W   !_!  4 %f   &h  	=&
 &	
r   r'   r+   r/   returnc                     [         U   u  pEUS-  S-  n[        R                  " XdU-  -  5      n[        XG-  U-  5      U-  n[        XW-  U-  5      U-  n	[        R
                  " X5      $ )Ni   )r!   mathsqrtroundr   
NodeOutput)
rB   r'   r+   r/   w_ratioh_ratiototal_pixelsscaler4   r5   s
             r   executeResolutionSelector.executeK   so    (6!D(4/		,G*;<=go01H<w12X=}}U++r   r
   N)r   r   r   r   __doc__classmethodrC   strfloatintr   rJ   rO   r   r
   r   r   r#   r#      sL    L'
 '
R ,3 ,E ,S ,R]] , ,r   r#   c                   L    \ rS rSr\S\\\R                        4S j5       r	Sr
g)ResolutionExtensionU   rE   c                    #    [         /$ 7fN)r#   )selfs    r   get_node_list!ResolutionExtension.get_node_listV   s      
 	
s   
r
   N)r   r   r   r   r   listtyper   	ComfyNoder\   r   r
   r   r   rW   rW   U   s)    
T$r||*<%= 
 
r   rW   rE   c                     #    [        5       $ 7frZ   )rW   r
   r   r   comfy_entrypointrb   ]   s       s   )rG   enumr   typing_extensionsr   comfy_api.latestr   r   rS   r   r   r   r   r   r   r   r   r   r!   dicttuplerU   __annotations__r`   r#   rW   rb   r
   r   r   <module>ri      s      & /%#t % FFggW	5tKsCx01 	4, 4,n
. 
! 3 !r   