+
    ‚°ñj1  ã                  ó†   € R t ^ RIHt ^ RIt^ RIt^ RIHt ]P                  ! ]4      t	Rt
RtR R ltR R	 ltRR
 R lltR# )zéImage dimension extraction for asset ingest.

Reads only the image header via Pillow to capture width/height cheaply,
without a full pixel decode. Returns a metadata dict suitable for merging
into ``AssetReference.system_metadata``.
)ÚannotationsN)ÚAnys   v/1i   c               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚbytes© )Úformats   "ÚHC:\Ai_Coding\apps\studio\ComfyUI\app\assets\services\image_dimensions.pyÚ__annotate__r      s   € ÷ 1ñ 1˜ñ 1ó    c                ó¶   € \        4       p\        V4      ^ÿ8:  d6   V P                  ^4      pV'       d   VR8X  d   \        V4      # W,          pKE  \	        R4      h)éÿ   ó    zEXR header name too long)Ú	bytearrayÚlenÚreadr   Ú
ValueError)ÚfÚoutÚbs   &  r
   Ú_read_cstringr      sG   € Ü
‹+€CÜ
ˆc‹(�cŒ/Ø�F‰F�1‹Iˆß�A˜”JÜ˜“:ÐØ�ŠÜ
Ð/Ó
0Ð0r   c               ó    € V ^8„  d   QhRRRR/# )r   Ú	file_pathÚstrr   z.tuple[tuple[int, int], tuple[int, int]] | Noner   )r	   s   "r
   r   r      s   € ÷ ñ  ð Ð(Vñ r   c           	     ó|  € / p \        V R4      ;_uu_ 4       pVP                  ^4      \        8w  d    RRR4       R# VP                  ^4       \        \        4       FÙ  p\        V4      pV'       g    MÅ\        V4       \        P                  ! RVP                  ^4      4      w  pV^ 8  d    RRR4       R# VR9   dd   V^8X  d]   WA9   d    RRR4       R# \        P                  ! RVP                  ^4      4      w  rgr‰W†,
          ^,           W—,
          ^,           3W&   KÇ  VP                  V^4       KÛ  	  RRR4       TP                  R4      TP                  R4      rºT
e   Te   \        . T
OTO5!  ^ 8:  d   R# Y«3#   + '       g   i     LQ; i  \        \        \        P                  3 d     R# i ; i)z–(display, data) window sizes as (width, height), read from the header alone.

Pillow can't open EXR, and opening it with PyAV buffers the whole file.
ÚrbNz<ió   displayWindowó
   dataWindowz<4i)r   r   )Úopenr   Ú
_EXR_MAGICÚrangeÚ_EXR_MAX_ATTRIBUTESr   ÚstructÚunpackÚseekÚOSErrorr   ÚerrorÚgetÚmin)r   Úwindowsr   Ú_ÚnameÚsizeÚx_minÚy_minÚx_maxÚy_maxÚdisplayÚdatas   &           r
   Úread_exr_windowsr4      sp  € ð
 -/€GðÜ�)˜T×"Ô" aØ�v‰v�a‹yœJÔ&Ø÷ #Ñ"ð �F‰F�1ŒIÜÔ.Ö/�Ü$ QÓ'�ßÙÜ˜aÔ Ü Ÿ-š-¨¨a¯f©f°Q«iÓ8‘�Ø˜!”8Ø÷ #Ñ"ð Ð<Ô<ÀÈÄØ”Ø#÷ #Ñ"ô 28·²¸uÀaÇfÁfÈRÃjÓ1QÑ.�E %Ø%*¥]°QÕ%6¸½ÈÕ8IÐ$J�G“Mà—F‘F˜4 –Oñ 0÷	 #ð* —K‘KÐ 0Ó1°7·;±;¸}Ó3MˆTØ‚˜$š,¬#Ð*>¨wÐ*>¸Ó*>À!Ô*CÙØˆ=Ð÷1 #×"ûô& ”Z¤§¡Ð.ô ÚðúsR   „F ˜F´F ¾A3FÂ1F Â;FÃF ÃA!FÄ;F ÆF	ÆF ÆF Æ F;Æ:F;c               ó$   € V ^8„  d   QhRRRRRR/# )r   r   r   Ú	mime_typez
str | Noner   zdict[str, Any] | Noner   )r	   s   "r
   r   r   ?   s$   € ÷ 6?ñ 6?Øð6?Ø)ð6?àñ6?r   c                óh  € Ve   VP                  R4      '       g   R# VR8X  d!   \        V 4      pVf   R# Vw  w  r4pRRRVRV/#  ^ RIHpHp  TP                  T 4      ;_uu_ 4       pTP                  w  r4RRR4       \        X\        4      '       d%   \        X\        4      '       d   T^ 8:  g   T^ 8:  d   R# RRRTRT/#   \
         d    \        P                  R	T 4        R# i ; i  + '       g   i     L|; i  \        T\        3 d"   p	\        P                  R
Y	4        Rp	?	R# Rp	?	ii ; i)aª  Extract image dimensions for the file at ``file_path``.

Args:
    file_path: Absolute path to a file on disk.
    mime_type: Optional MIME type hint. When provided and not prefixed
        with ``image/``, extraction is skipped without touching the file.

Returns:
    ``{"kind": "image", "width": W, "height": H}`` when the file is a
    recognizable image with positive dimensions, otherwise ``None``.

The dict shape is intended to be merged into ``system_metadata`` so the
asset response surfaces ``metadata.kind`` plus dimension fields for image
assets. Forward-compatible: future media kinds (e.g. ``"video"`` with
duration/fps) can extend this shape without schema changes.
Nzimage/zimage/x-exrÚkindÚimageÚwidthÚheight)ÚImageÚUnidentifiedImageErrorz@Pillow not available; skipping image dimension extraction for %sz+Failed to read image dimensions from %s: %s)Ú
startswithr4   ÚPILr<   r=   ÚImportErrorÚloggerÚdebugr   r-   r&   r   Ú
isinstanceÚint)
r   r6   r*   r:   r;   r+   r<   r=   ÚimgÚexcs
   &&        r
   Úextract_image_dimensionsrG   ?   s"  € ð& Ò Y×%9Ñ%9¸(×%CÒ%CÙØ�MÔ!Ü" 9Ó-ˆØŠ?ÙØ$Ñ‰ˆ˜Ø˜ ¨%°¸6ÐBÐBðß5ðØ�Z‰Z˜	×"Ô" cØŸH™H‰MˆE÷ #ô �uœc×"Ò"Ü˜&¤#×&Ò&Ø�AŒ:Ø�QŒ;áà�G˜W e¨X°vÐ>Ð>øô1 ô Ü�‰ØNØô	
ò ðú÷ #×"ûäÐ+¬ZÐ8ô Ü�‰Ø9¸9ô	
õ ûð	úsH   ÁC ÁC> Á(C+Á7C> Ã!C(Ã'C(Ã+C;	Ã6C> Ã;C> Ã>D1ÄD,Ä,D1)N)Ú__doc__Ú
__future__r   Úloggingr#   Útypingr   Ú	getLoggerÚ__name__rA   r    r"   r   r4   rG   r   r   r
   Ú<module>rN      sH   ðñõ #ã Û Ý à	×	Ò	˜8Ó	$€à €
ØÐ õ1õ÷D6?ñ 6?r   