+
    åûj@^  ã                  óÎ  a € 0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ^ RIHtHt ^ RIt^ RIt^ RIHt ^ RIt^ RIHtHt ^ RIHtHtHt ^ R	IHtHt R.tR
 R lt  ! R R]4      t!Rt"R R lt#^ R^R^R/t$R]%R&   ]&! 0 R/m4      t'R R lt(R R lt)R R lt*R R lt+R R lt,R R  lt-R! R" lt.]!P^                  R#3R$ R% llt0R& R' lt1R( R) lt2R* R+ lt3R0R, R- llt4R# )1é    )ÚannotationsN)ÚEnum)ÚPath)ÚAnyÚUnion)Úio)ÚKORNIA_CHECKÚKORNIA_CHECK_IS_TENSOR)Ú
ShapeErrorÚTypeCheckErrorÚValueCheckError)Úimage_to_tensorÚtensor_to_imagec               ó    € V ^8„  d   QhRRRR/# )é   Úimg_npr   ÚreturnÚstr© )Úformats   "ÚHC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\io\io.pyÚ__annotate__r   (   s   € ÷ >ñ >˜ð > ñ >ó    c                óB   € ^R^R^R/V P                   R,          ,          # )zKReturn the kornia_rs colour mode of an HxWxC array with 1, 3 or 4 channels.ÚmonoÚrgbÚrgbaéÿÿÿÿ)Úshape)r   s   &r   Ú_color_moder    (   s#   € àˆv�q˜%  FÐ+¨F¯L©L¸Õ,<Õ=Ð=r   c                  ó2   € ] tR t^-tRt^ t^t^t^t^t	^t
RtR# )ÚImageLoadTypea}  Choose the channels, dtype and range of the tensor that load_image returns.

``load_image(path, ImageLoadType.RGB8)`` and its siblings choose what :func:`load_image` returns:

- ``GRAY8``, ``RGB8``, ``RGBA8``: 1, 3 or 4 ``uint8`` channels in :math:`[0, 255]`, from any 8-bit file.
- ``GRAY32``, ``RGB32``: 1 or 3 ``float32`` channels in :math:`[0, 1]`, from any 8-bit file.
- ``UNCHANGED``: the file's channels and dtype, ``uint8``, ``uint16`` or ``float32``.

The Convention block of :func:`load_image` says how alpha, palettes and gray conversion are handled.

See Also:
    - :func:`load_image`: takes the member as ``desired_type``.
r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	UNCHANGEDÚGRAY8ÚRGB8ÚRGBA8ÚGRAY32ÚRGB32Ú__static_attributes__r   r   r   r"   r"   -   s'   † ñð €IØ€EØ€DØ€EØ€FØ„Er   r"   s   ‰PNG

c               ó    € V ^8„  d   QhRRRR/# )r   Ú	path_filer   r   ztuple[int, int] | Noner   )r   s   "r   r   r   G   s   € ÷ &ñ & ð &Ð)?ñ &r   c                ó  € \        V R4      ;_uu_ 4       pVP                  ^4      p\        V4      ^8  g   VR,          \        8w  d    RRR4       R# V^,          V^,          3uuRRR4       #   + '       g   i     R# ; i)a  Read the bit depth and color type bytes from a PNG file header.

Returns ``(bit_depth, color_type)``, in that order, or None if the file is truncated or has an invalid PNG
signature.
PNG color types: 0=Grayscale, 2=RGB, 3=Indexed, 4=Grayscale+Alpha, 6=RGBA.
Úrb:Né   NN)ÚopenÚreadÚlenÚ_PNG_SIGNATURE)r0   ÚfÚheaders   &  r   Ú_read_png_headerr:   G   sc   € ô 
ˆi˜×	Ô	 !à—‘˜“ˆÜˆv‹;˜Ô˜v b�z¬^Ô;Ø÷	 
Ñ	ð
 �b�z˜6 "�:Ð%÷ 
×	×	Ó	ús   •5A0ÁA0Á0B	r   r   zdict[int, str]Ú_PNG_COLOR_TYPE_TO_MODEc               ó    € V ^8„  d   QhRRRR/# )r   r0   r   r   z
int | Noner   )r   s   "r   r   r   e   s   € ÷ Cñ C Tð C¨jñ Cr   c                ó  € \        V R4      ;_uu_ 4       pVP                  ^4      R8w  d    RRR4       R#  VP                  ^4      R8w  d    RRR4       R# VP                  ^4      pVR8X  d   VP                  ^4      pK  V'       g    RRR4       R# V^ ,          pV^8X  g   ^ÐTu;8:  d   ^×8:  d   M MK„  VP                  ^4      p\        V4      ^8  d    RRR4       R# V\        9   d7   VP                  ^4      p\        V4      ^8X  d
   V^,          MRuuRRR4       # V^Ú8X  d    RRR4       R# VP	                  \
        P                  VR4      ^,
          \        P                  4       EKA    + '       g   i     R# ; i)zgReturn the number of colour components in a JPEG frame header, or None if the file has no readable one.r2   s   ÿØNó   ÿÚbig)	r4   r5   r6   Ú_JPEG_SOF_MARKERSÚseekÚintÚ
from_bytesÚosÚSEEK_CUR)r0   r8   ÚcodeÚmarkerÚlengthÚframes   &     r   Ú_read_jpeg_componentsrJ   e   s8  € ä	ˆi˜×	Ô	 !Ø�6‰6�!‹9˜Ô#Ø÷ 
Ñ	ð Ø�v‰v�a‹y˜GÔ#Ø÷ 
Ñ	ð —6‘6˜!“9ˆDØ˜'”/Ø—v‘v˜a“y’ßØ÷ 
Ñ	ð ˜!•WˆFØ˜Œ~ ¨Ö!7°4×!7ÙØ—V‘V˜A“YˆFÜ�6‹{˜QŒØ÷! 
Ñ	ð" Ô*Ô*ØŸ™˜q›	�Ü#& u£:°¤?�u˜Q–x¸÷' 
Ò	ð( ˜Œ~Ø÷+ 
Ñ	ð, �F‰F”3—>‘> &¨%Ó0°1Õ4´b·k±k×B÷- 
×	Ð	ús5   •E8·E8Á2E8ÂE8ÂAE8Ã'6E8Ä(E8Ä:>E8Å8F		c               ó    € V ^8„  d   QhRRRR/# )r   r0   r   r   z!tuple[bytes | None, bytes | None]r   )r   s   "r   r   r   €   s   € ÷ ñ  ð Ð)Jñ r   c           	     ó<  € RpRp\        V R4      ;_uu_ 4       pVP                  ^4      \        8w  d   RuuRRR4       #  VP                  ^4      pVR,          p\        V4      ^8  g   VR9   d   EM
\        P                  VR,          R4      pVR9  d*   VP                  V^,           \        P                  4       K�  VP                  V4      pVP                  ^4      pVP                  R4      p	\        V4      V8  g   \        V4      ^8  d   \        RV  R	V	 R
24      h\        P                  VR4      \        P                  ! WW,           4      8w  d   \        RV  R	V	 R24      hVR8X  d   TpEK9  TpEK>  RRR4       W3#   + '       g   i     Y3# ; i)a"  Return the raw bodies of a PNG's PLTE and tRNS chunks, None for a chunk the file does not have.

Both chunks are checked as a PNG decoder checks them: a truncated body or a stored CRC that does not match the
chunk raises ``ValueError`` naming the file. Every other chunk is skipped unread.
Nr2   :é   r3   N:NrM   Nr?   ó   PLTEÚasciiúFailed to decode image 'z': its z chunk is truncated.z chunk fails its CRC check.©NN)s   IDATs   IEND)rN   s   tRNS)r4   r5   r7   r6   rB   rC   rA   rD   rE   ÚdecodeÚ
ValueErrorÚzlibÚcrc32)
r0   ÚplteÚtrnsr8   ÚheadÚkindÚsizeÚbodyÚcrcÚnames
   &         r   Ú_read_png_chunksr^   €   sf  € ð €DØ€DÜ	ˆi˜×	Ô	 !Ø�6‰6�!‹9œÔ&Ø÷ 
Ò	ð Ø—6‘6˜!“9ˆDØ˜•9ˆDÜ�4‹y˜1Œ} Ð(:Ô :ÙÜ—>‘> $ r¥(¨EÓ2ˆDØÐ-Ô-Ø—‘�t˜a•x¤§¡Ô-ÙØ—6‘6˜$“<ˆDØ—&‘&˜“)ˆCØ—;‘;˜wÓ'ˆDÜ�4‹y˜4Ô¤3 s£8¨a¤<Ü Ð#;¸I¸;ÀgÈdÈVÐSgÐ!hÓiÐiÜ�~‰~˜c 5Ó)¬T¯ZªZ¸½Ó-DÔDÜ Ð#;¸I¸;ÀgÈdÈVÐSnÐ!oÓpÐpØ�wŒØ“à“÷- 
ð. ˆ:Ð÷/ 
Ö	ð. ˆ:Ðús   ™F	Á D>F	Æ	F	c               ó$   € V ^8„  d   QhRRRRRR/# )r   r0   r   Úimageútorch.Tensorr   r   )r   s   "r   r   r   ¢   s"   € ÷ ->ñ ->°4ð ->Àð ->ÐQ]ñ ->r   c           	     óì  € V P                   P                  4       R8w  d   V# \        V 4      pVe   V^,          R9  d   V# Vw  r4\        V 4      w  rVV^8X  Ed   Vf   V# \	        V4      ^,          '       d   \        RV  R\	        V4       R24      h\        P                  ! \        V4      \        P                  R7      P                  R^4      pTpVe·   \        P                  ! VP                  ^ ,          3^ÿ\        P                  R7      p	V'       dV   \        P                  ! \        V4      \        P                  R7      RVP                  ^ ,           p
W©RV
P                  4       % \        P                  ! WyR,          .^R7      pV^ ,          P                  4       pVP                  4       '       dm   \!        VP#                  4       4      VP                  ^ ,          8¼  d>   \        RV  R\!        VP#                  4       4       R	VP                  ^ ,           R
24      hVP%                  VP&                  4      V,          P)                  ^^ ^4      P+                  4       # V^ 8X  d   ^M^pV^8w  g   Ve   \	        V4      ^V,          8  d   V# \        P,                  ! \/        V4       Uu. uF  qÖ^V,          ^,           ,          NK  	  up\        P                  VP&                  R7      pWR,          8H  P1                  ^ RR7      p\        P2                  ! V^ ^ÿ4      P%                  \        P                  4      p	\        P                  ! VP5                  ^RR4      V	.^ R7      # u upi )a¦  Apply a PNG's palette and tRNS chunk to the decoded pixels; any other file is returned unchanged.

An 8-bit palette PNG (colour type 3) becomes ``(3, H, W)`` colours, or ``(4, H, W)`` with a tRNS chunk, whose
per-entry alphas leave unlisted entries opaque. An 8-bit gray or RGB PNG (colour types 0 and 2) with a tRNS colour
key becomes ``(4, H, W)`` RGBA, with alpha 0 where every sample equals the key and 255 elsewhere.
ú.pngNrP   z': its PLTE chunk has z* bytes, not a whole number of RGB entries.)Údtype)Údimz': a pixel uses palette entry z, but the palette has z	 entries.)rd   ÚdeviceT)re   Úkeepdim)r   r   é   r   )ºNNNN)ri   NN)ÚsuffixÚlowerr:   r^   r6   rS   ÚtorchÚ
frombufferÚ	bytearrayÚuint8ÚviewÚfullr   ÚnumelÚcatÚlongrB   ÚmaxÚtorf   ÚpermuteÚ
contiguousÚtensorÚrangeÚallÚwhereÚexpand)r0   r`   r9   Ú	bit_depthÚ
color_typerV   rW   ÚcolorsÚtableÚalphaÚlistedÚindicesÚ	n_samplesÚiÚkeyÚtransparents   &&              r   Ú#_apply_png_palette_and_transparencyr‰   ¢   sÍ  € ð ×Ñ×ÑÓ 6Ô)ØˆÜ˜iÓ(€FØ‚~˜ �¨)Ô3ØˆØ"Ñ€IÜ! )Ó,�J€DØ�Q…ØŠ<ØˆLÜˆt‹9�q�=Œ=ÜØ*¨9¨+Ð5KÌCÐPTËIÈ;ð Wð óð ô ×!Ò!¤)¨D£/¼¿¹ÔE×JÑJÈ2ÈqÓQˆØˆØÒÜ—J’J §¡¨Q¥Ð1°3¼e¿k¹kÔJˆEßÜ×)Ò)¬)°D«/ÄÇÁÔMÐN_ÐPV×P\ÑP\Ð]^ÕP_Ð`�Ø*0Ð&˜Ÿ™›Ð'Ü—I’I˜v¨W¥~Ð6¸AÔ>ˆEØ˜•(—-‘-“/ˆØ�=‰=�?Š?œs 7§;¡;£=Ó1°U·[±[Àµ^ÔCÜØ*¨9¨+Ð5SÔTWÐX_×XcÑXcÓXeÓTfÐSgð h'Ø',§{¡{°1¥~Ð&6°iðAóð ð �x‰x˜Ÿ™Ó% gÕ.×6Ñ6°q¸!¸QÓ?×JÑJÓLÐLð   1”_‘¨!€IØ�A„~˜š¬¨T«°Q¸µ]Ô)BØˆÜ
�,Š,´°yÔ1AÓBÑ1A¨A˜Q �U Q�YŸ˜Ñ1AÑBÌ%Ï+É+Ð^c×^jÑ^jÔ
k€CØ Õ.Ñ.×3Ñ3¸À4Ð3ÓH€KÜ�KŠK˜ Q¨Ó,×/Ñ/´·±Ó<€EÜ�9Š9�e—l‘l 1 b¨"Ó-¨uÐ5¸1Ô=Ð=ùò Cs   Ê4M1c               ó$   € V ^8„  d   QhRRRRRR/# )r   r0   r   rf   úUnion[str, torch.device, None]r   ra   r   )r   s   "r   r   r   Ò   s#   € ÷ 3 ñ 3  Tð 3 Ð3Qð 3 ÐVbñ 3 r   c                ó  €  \        V R4      ;_uu_ 4         RRR4       V P                  P                  4       R
9   dN   \        P                  ! \        V 4      4      p\        V 4      ^8X  d   \        P                  ! VR,          4      pMßV P                  P                  4       R8X  d¡   \        V 4      ;'       g    Rw  r4\        P                  V4      pVe   VR8X  d!   \        P                  ! \        V 4      4      pMiV^8X  d"   \        P                  ! \        V 4      V4      pMA\        P                  ! \        V 4      V4      pM \        P                  ! \        V 4      4      p \%        VRR7      p\'        V\(        P*                  4      '       g   Vf   TM\(        P*                  ! V4      pVP-                  VR	7      #   + '       g   i     EL·; i  \         d    h \          d   p\#        RT  RT 24      ThRp?ii ; i)ax  Read an image file and decode using the Kornia Rust backend.

The decoded image is returned as numpy array with shape HxWxC.

Args:
    path_file: Path to an image file in a format kornia-rs decodes; the extension may be in any letter case.
    device: the device where you want to get your image placed.

Return:
    Image torch.Tensor with shape ``(C, H, W)``, as decoded.

r2   Nrc   r   rP   z': T)rg   )rf   ©ú.jpgú.jpeg).:Né   NrQ   )r4   rj   rk   Ú_rs_ioÚread_image_jpegturbor   rJ   ÚnpÚascontiguousarrayr:   r;   ÚgetÚ
read_imageÚread_image_png_u16Úread_image_png_u8ÚOSErrorÚ	ExceptionrS   r   Ú
isinstancerl   rf   rv   )	r0   rf   Úimgr~   r   ÚmodeÚeÚimg_tÚdevs	   &&       r   Ú_load_image_to_tensorr¡   Ò   s�  € ðNô �)˜T×"Õ"Ø÷ #à×Ñ×!Ñ!Ó#Ð'8Ô8Ü×-Ò-¬c°)«nÓ=ˆCÜ$ YÓ/°1Ô4ô ×*Ò*¨3¨w­<Ó8�øØ×Ñ×#Ñ#Ó%¨Ô/ä$4°YÓ$?×$OÐ$OÀ<Ñ!ˆIÜ*×.Ñ.¨zÓ:ˆDØŠ|˜t uœ}ä×'Ò'¬¨I«Ó7‘Ø˜b”ä×/Ò/´°I³ÀÓE‘ä×.Ò.¬s°9«~¸tÓD‘ä×#Ò#¤C¨	£NÓ3‰Cô ˜C¨Ô.€Eô ˜v¤u§|¡|×4Ò4¸º‰&ÌEÏLÊLÐY_ÓL`€Cà�8‰8˜3ˆ8ÓÐ÷C #×"Ð"ûô, ô ØÜô NÜÐ3°I°;¸cÀ!ÀÐEÓFÈAÐMûðNúsS   ‚G –G˜A3G Â0G Â=AG Ä'G Ä* G ÅG ÇG	Ç	G ÇHÇ/HÇ0HÈHc               ó    € V ^8„  d   QhRRRR/# ©r   r`   ra   r   r   )r   s   "r   r   r     s   € ÷ !ñ !�|ð !¨ñ !r   c                ó|   € \        V P                  \        P                  8H  4       V P	                  4       R,          # )z)Convert an image torch.Tensor to float32.ç     ào@)r	   rd   rl   ro   Úfloat©r`   s   &r   Ú_to_float32r¨     s(   € ä�—‘¤§¡Ñ+Ô,Ø�;‰;‹=˜5Õ Ð r   c               ó    € V ^8„  d   QhRRRR/# r£   r   )r   s   "r   r   r     s   € ÷ Dñ D�\ð D lñ Dr   c                óæ   € \        V P                  \        P                  8H  4       V P	                  R4      P                  4       P                  ^ ^ÿ4      P                  \        P                  4      # )zHConvert a float image in [0, 1] to uint8, rounding to the nearest level.r¥   )	r	   rd   rl   Úfloat32ÚmulÚround_Úclamp_rv   ro   r§   s   &r   Ú	_to_uint8r¯     sK   € ä�—‘¤§¡Ñ-Ô.Ø�9‰9�UÓ×"Ñ"Ó$×+Ñ+¨A¨sÓ3×6Ñ6´u·{±{ÓCÐCr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r`   ra   Údesired_typer"   r   r   )r   s   "r   r   r     s&   € ÷ .hñ .h˜|ð .h¸=ð .hÈ\ñ .hr   c           	     ó”  € V P                   ^ ,          pV\        P                  8X  d   V # V P                  \        P
                  8w  d'   \        RV P                   RVP                   R24      hV^8X  dI   V\        P                  8w  d4   \        \        P                  P                  \        V 4      4      4      p ^pW3; d'    ^8H  d    w  \        P                  8X  d
   ^8X  d    V #  ; dD    ^8H  d=   w  \        P                  8X  d'   ^8X  d"    \        P                  P                  V 4      #  ; d'    ^8H  d    w  \        P                   8X  d
   ^8X  d    V #  ; dD    ^8H  d=   w  \        P                   8X  d'   ^8X  d"    \        P                  P#                  V 4      #  ; d'    ^8H  d    w  \        P                  8X  d
   ^8X  d    V #  ; dW    ^8H  dP   w  \        P                  8X  d:   ^8X  d5    \        \        P                  P%                  \        V 4      R4      4      #  ; dt    ^8H  dm   w  \        P                  8X  dW   ^8X  dR    \        \        P                  P%                  \        P                  P#                  \        V 4      4      R4      4      #  ; d0    ^8H  d)   w  \        P&                  8X  d   ^8X  d    \        V 4      #  ; dM    ^8H  dF   w  \        P&                  8X  d0   ^8X  d+    \        P                  P                  \        V 4      4      #  ; d0    ^8H  d)   w  \        P(                  8X  d   ^8X  d    \        V 4      #   dL    ^8H  dE   w  \        P(                  8X  d/   ^8X  d*   \        P                  P#                  \        V 4      4      #   \        RV RV 24      h)a;  Convert a raw CxHxW uint8 image tensor to the desired type.

``UNCHANGED`` returns whatever the decoder produced, so a 16-bit PNG or TIFF comes back as ``uint16`` and a
float TIFF as ``float32``. Every other load type is defined for 8-bit input; asking for one on a wider
decode raises rather than mislabelling it.
zThe file decoded to z, and ImageLoadType.zh is defined for 8-bit images only; load it with ImageLoadType.UNCHANGED and convert the tensor yourself.g      ð?zUnsupported conversion: z channels to )r   r"   r(   rd   rl   ro   ÚNotImplementedErrorr]   r+   r¯   ÚkorniaÚcolorÚrgba_to_rgbr¨   r)   Úrgb_to_grayscaler*   Úgrayscale_to_rgbÚrgb_to_rgbar,   r-   )r`   r±   Úchannelss   && r   Ú_convert_image_typer»     s‚  € ð �{‰{˜1�~€Hà”}×.Ñ.Ô.ØˆØ‡{�{”e—k‘kÔ!Ü!Ø" 5§;¡; -Ð/CÀL×DUÑDUÐCVð WZð Zó
ð 	
ð �1„}˜¬×)<Ñ)<Ô<Üœ&Ÿ,™,×2Ñ2´;¸uÓ3EÓFÓGˆØˆàÐ
"ß%Õ%Œm×!Ö!¥1ÙˆLð &ç%Õ%Œm×!Ö!¥1Ý—<‘<×0Ñ0°Ó7Ð7ð &ç$Õ$Œm× Ö ¥!ÙˆLð %ç$Õ$Œm× Ö ¥!Ý—<‘<×0Ñ0°Ó7Ð7ð %ç%Õ%Œm×!Ö!¥1ÙˆLð &ç%Õ%Œm×!Ö!¥1ÝœVŸ\™\×5Ñ5´kÀ%Ó6HÈ#ÓNÓOÐOð &ç%Õ%Œm×!Ö!¥1ÝœVŸ\™\×5Ñ5´f·l±l×6SÑ6SÔT_Ð`eÓTfÓ6gÐilÓmÓnÐnð &ç&Õ&Œm×"Ö"¥AÝ˜uÓ%Ð%ð 'ç&Õ&Œm×"Ö"¥AÝ—<‘<×0Ñ0´¸UÓ1CÓDÐDð 'ç%Õ%Œm×!Ö!¥1Ý˜uÓ%Ð%ð &ç%Ô%Œm×!Ö!¥1Ü—<‘<×0Ñ0´¸UÓ1CÓDÐDð &àÜ%Ð(@ÀÀ
È-ÐXdÐWeÐ&fÓgÐgr   Úcpuc               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r0   ú
str | Pathr±   r"   rf   r‹   r   ra   r   )r   s   "r   r   r   E  s0   € ÷ >4ñ >4Øð>4àð>4ð +ð>4ð ñ	>4r   c                ó  € \        V\        4      '       g!   \        RV: R2\        V4      \        R7      h\        V \        4      '       g   \	        V 4      p \        W4      pV\        P                  8w  d   \        W4      p\        W14      # )a9
  Load a JPEG, PNG, TIFF or WebP file into a ``(C, H, W)`` tensor of a chosen type.

``image = load_image(path_file, desired_type, device)`` decodes the file with kornia-rs on the CPU and returns a
``(C, H, W)`` tensor in RGB order, alpha last, on ``device``. ``desired_type``, an :class:`ImageLoadType`, fixes the
channels, dtype and range; the default ``RGB32`` gives ``(3, H, W)`` ``float32`` in :math:`[0, 1]`.

Convention:
    - Under ``UNCHANGED`` a 16-bit PNG or TIFF loads as ``uint16`` and a float TIFF as ``float32``; the other
      types raise for such a file.
    - Under every type except ``UNCHANGED``, an 8-bit palette PNG loads as its colors and a PNG ``tRNS`` chunk
      counts as alpha; palette entries the chunk does not list, all of them for an empty chunk, are opaque.
      ``RGBA8`` keeps the alpha (255 for an opaque file), and the other types composite it over white, rounded to
      the nearest level. ``UNCHANGED`` returns a palette PNG's indices and keeps an alpha channel as stored.
    - ``GRAY8`` and ``GRAY32`` convert a color file with :func:`~kornia.color.rgb_to_grayscale`.
    - The pixels come back as stored: the EXIF orientation is ignored.
    - The extension, in any letter case, chooses the decoder; the file content does not.
    - kornia-rs cannot decode a PNG with 1, 2 or 4 bits per sample, a gray+alpha PNG, a 4-channel TIFF or a CMYK
      JPEG; these, a truncated file and, under every type except ``UNCHANGED``, a malformed palette or
      ``PLTE``/``tRNS`` chunk raise ``ValueError``.
    - :ref:`Files and arrays <image-io-conventions>` maps OpenCV's and Pillow's loaders onto the load types.

Args:
    path_file: Path to an image file in a format kornia-rs decodes.
    desired_type: the desired image type, defined by color space and dtype.
    device: the device where you want to get your image placed.

Return:
    Image torch.Tensor with shape ``(C, H, W)``.

Raises:
    TypeCheckError: if ``desired_type`` is not an :class:`ImageLoadType` (also a ``TypeError``).
    OSError: if the file cannot be read, for example ``FileNotFoundError`` when it does not exist.
    ValueError: if the file cannot be decoded; the message names the file.
    NotImplementedError: if a type other than ``UNCHANGED`` is requested for a file wider than 8 bits.

See Also:
    - :func:`write_image`: the other direction, a tensor to a file.
    - :meth:`~kornia.image.Image.from_file`: loads a file into an :class:`~kornia.image.Image` container, always
      as ``RGB8``.
    - :func:`get_sample_images`: loads several files or URLs at once, optionally resized and stacked.

z+desired_type must be an ImageLoadType, got Ú.©Úactual_typeÚexpected_type)	r›   r"   r   Útyper   r¡   r(   r‰   r»   )r0   r±   rf   r`   s   &&& r   Ú
load_imagerÅ   E  s~   € ô^ �l¤M×2Ò2ÜØ9¸,Ñ9IÈÐKÜ˜\Ó*Ü'ô
ð 	
ô
 �i¤×&Ò&Ü˜“Oˆ	ô 0°	ÓB€Eà”}×.Ñ.Ô.Ü3°IÓEˆä˜uÓ3Ð3r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r0   r   r   r   ÚqualityrB   r   ÚNoner   )r   s   "r   r   r   †  s.   € ÷ 
eñ 
e $ð 
e°ð 
e¸cð 
eÀdñ 
er   c                óØ  € \        V4      pV P                  P                  4       R9   d%   \        P                  ! \        V 4      WVR7       R# V P                  P                  4       R8X  d$   \        P                  ! \        V 4      WR7       R# V P                  P                  4       R9   d$   \        P                  ! \        V 4      WR7       R# \        RV P                   R24      h)	zWrite uint8 image to file.)r�   rÇ   rc   ©r�   úUnsupported file extension: z for uint8 imageNr�   ©ú.tifú.tiff)	r    rj   rk   r‘   Úwrite_image_jpegr   Úwrite_image_png_u8Úwrite_image_tiff_u8r³   )r0   r   rÇ   r�   s   &&& r   Ú_write_uint8_imagerÒ   †  s®   € ä�vÓ€DØ×Ñ×ÑÓÐ#4Ô4Ü×Ò¤ I£°È7×SØ	×	Ñ	×	Ñ	Ó	! VÔ	+Ü×!Ò!¤# i£.°&×DØ	×	Ñ	×	Ñ	Ó	!Ð%6Ô	6Ü×"Ò"¤3 y£>°6×Eä!Ð$@À×AQÑAQÐ@RÐRbÐ"cÓdÐdr   c               ó$   € V ^8„  d   QhRRRRRR/# ©r   r0   r   r   r   r   rÈ   r   )r   s   "r   r   r   “  s&   € ÷ fñ f 4ð f°ð f¸ñ fr   c                óR  € \        V4      pV P                  P                  4       R8X  d$   \        P                  ! \        V 4      WR7       R# V P                  P                  4       R9   d$   \        P                  ! \        V 4      WR7       R# \        RV P                   R24      h)zWrite uint16 image to file.rc   rÊ   rË   z for uint16 imageNrÌ   )r    rj   rk   r‘   Úwrite_image_png_u16r   Úwrite_image_tiff_u16r³   ©r0   r   r�   s   && r   Ú_write_uint16_imagerÙ   “  s€   € ä�vÓ€DØ×Ñ×ÑÓ 6Ô)Ü×"Ò"¤3 y£>°6×EØ	×	Ñ	×	Ñ	Ó	!Ð%6Ô	6Ü×#Ò#¤C¨	£N°F×Fä!Ð$@À×AQÑAQÐ@RÐRcÐ"dÓeÐer   c               ó$   € V ^8„  d   QhRRRRRR/# rÔ   r   )r   s   "r   r   r   ž  s&   € ÷ gñ g Dð g°#ð g¸$ñ gr   c                óÎ   € \        V4      pV P                  P                  4       R9   d$   \        P                  ! \        V 4      WR7       R# \        RV P                   R24      h)zWrite float32 image to file.rÊ   rË   z for float32 imageNrÌ   )r    rj   rk   r‘   Úwrite_image_tiff_f32r   r³   rØ   s   && r   Ú_write_float32_imagerÝ   ž  sU   € ä�vÓ€DØ×Ñ×ÑÓÐ#4Ô4Ü×#Ò#¤C¨	£N°F×Fä!Ð$@À×AQÑAQÐ@RÐRdÐ"eÓfÐfr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r0   r¾   r`   ra   rÇ   rB   r   rÈ   r   )r   s   "r   r   r   §  s5   € ÷ bMñ bM˜:ð bM¨lð bMÀSð bMÐRVñ bMr   c           	     ó”  € \        V \        4      '       g   \        V 4      p \        V4       \        V\        P                  4      '       d   \        V\
        4      '       d+   \        RV: R2\        V4      \        P                  R7      h^ Tu;8:  d   ^d8:  g   M \        RV: R2VRR7      hV P                  P                  4       p\        V\        9   RV  R24       VP                  4       R9  d;   \        R\        VP                   4       R2\        VP                   4      . ROR	7      hVP                   R,          VP                   R,          rTV^ 8:  g   V^ 8:  d8   \        R
\        VP                   4       R2\        VP                   4      R7      hV P"                  pVP%                  4       '       g{   VP'                  4       '       d3   \)        \*        P,                  RV P.                   R2\1        V4      4      h\3        \*        P4                  RV P.                   R2\1        V4      4      h\7        VRRR7      pVP8                  ^8X  d
   VR,          pVP                   R,          pVR8X  d   RMR p	W‰9  d+   \        RV RV RV	 R2\        VP                   4      R7      hVP:                  \<        P>                  8X  d   \A        WV4       R# VP:                  \<        PB                  8X  d   \E        W4       R# VP:                  \<        PF                  8X  d   \I        W4       R# \K        RVP:                   24      h)!aÍ  Write a ``(C, H, W)`` or ``(H, W)`` tensor to a JPEG, PNG or TIFF file, unscaled.

``write_image(path_file, image)`` encodes the tensor with kornia-rs in the format the extension names. JPEG takes
``uint8``, PNG ``uint8`` and ``uint16``, and TIFF ``uint8``, ``uint16`` and ``float32``; each takes 1 or 3
channels, and PNG also 4. For a ``float32`` image in :math:`[0, 1]`, write ``(image * 255).round().to(torch.uint8)``
to JPEG or PNG.

Convention:
    - The tensor is written in RGB order with alpha last, without conversion, scaling or clamping: a ``float32``
      TIFF keeps values outside :math:`[0, 1]`.
    - ``image`` is channels first. A channels-last ``(H, W, C)`` tensor is not detected: its first axis is
      read as the channels.
    - :ref:`Files and arrays <image-io-conventions>` maps ``cv2.imwrite`` onto these arguments.
    - An image with zero height or width raises ``ShapeError`` before anything is written, so no empty or
      truncated file is left behind.

Args:
    path_file: Path with a .jpg, .jpeg, .png, .tif or .tiff extension, in any letter case.
    image: Image torch.Tensor with shape ``(C, H, W)`` or ``(H, W)``.
    quality: The quality of the JPEG encoding, an integer in :math:`[0, 100]` and not a ``bool``. It is validated
        for every format and used only for JPEG.

Return:
    None.

Raises:
    TypeCheckError: if ``image`` is not a tensor or ``quality`` is not an integer (also a ``TypeError``).
    ValueCheckError: if ``quality`` is outside :math:`[0, 100]` (also a ``ValueError``).
    BaseError: if the extension is not one of the five above.
    ShapeError: if ``image`` is not 2-D or 3-D, the height or width is not positive, or the format cannot
        store its channels (also a ``ValueError``).
    FileNotFoundError: if the directory to write into does not exist (``NotADirectoryError`` if it is a file).
    NotImplementedError: if the format cannot store the dtype.
    Exception: kornia-rs's bare ``Exception`` when the file cannot be created or the image cannot be encoded.

See Also:
    - :func:`load_image`: the other direction, a file to a tensor.
    - :meth:`~kornia.image.Image.write`: writes an :class:`~kornia.image.Image`, converting BGR and channels-last
      data first.
z,quality must be an integer in [0, 100], got rÀ   rÁ   )Úactual_valueÚexpected_rangezInvalid file extension: z7, only .jpg, .jpeg, .png, .tif and .tiff are supported.zInvalid image shape: z. Expected (C, H, W) or (H, W).)Úactual_shapeÚexpected_shapezCannot write an image of shape z(: the height and width must be positive.)râ   zCannot write z into a filezNo such directory to write z intoT)rg   Úforce_contiguousNrc   zCannot write a z-channel image to z#; the supported channel counts are zUnsupported image dtype: )r   éd   )r   rh   )ÚCÚHÚWéþÿÿÿr   ).N)r�   rh   rM   )r�   rh   )&r›   r   r
   ÚnumbersÚIntegralÚboolr   rÄ   r   rj   rk   r	   Ú_WRITE_EXTENSIONSre   r   Útupler   ÚparentÚis_dirÚexistsÚNotADirectoryErrorÚerrnoÚENOTDIRr]   r   ÚFileNotFoundErrorÚENOENTr   Úndimrd   rl   ro   rÒ   Úuint16rÙ   r«   rÝ   r³   )
r0   r`   rÇ   rj   ÚheightÚwidthrï   r   rº   Ú	supporteds
   &&&       r   Úwrite_imagerü   §  s»  € ôR �i¤×&Ò&Ü˜“Oˆ	ä˜5Ô!Ü�gœw×/Ñ/×0Ò0´J¸wÌ×4MÒ4MÜØ:¸7¹+ÀQÐGÜ˜W›Ü!×*Ñ*ô
ð 	
ð
 �Ö˜3ÖÜØ:¸7¹+ÀQÐGÐV]Ðnvô
ð 	
ð ×Ñ×#Ñ#Ó%€FÜØÔ#Ñ#Ø
" 9 +Ð-dÐeôð ‡y�yƒ{˜&Ô ÜØ#¤E¨%¯+©+Ó$6Ð#7Ð7VÐWÜ˜uŸ{™{Ó+Ú*ô
ð 	
ð —K‘K •O U§[¡[°¥_ˆEØ�„{�e˜q”jÜØ-¬e°E·K±KÓ.@Ð-AÐAiÐjÜ˜uŸ{™{Ó+ô
ð 	
ð
 ×Ñ€FØ�=‰=�?Š?Ø�=‰=�?Š?Ü$¤U§]¡]°mÀIÇNÁNÐCSÐS_Ð4`ÔbeÐflÓbmÓnÐnÜ¤§¡Ð0KÈIÏNÉNÐK[Ð[`Ð.aÔcfÐgmÓcnÓoÐoä˜U¨DÀ4ÔH€FØ‡{�{�aÔØ˜	Õ"ˆØ�|‰|˜BÕ€HØ# vÔ-‘	°6€IØÔ ÜØ˜h˜ZÐ'9¸&¸ÐAdÐenÐdoÐopÐqÜ˜uŸ{™{Ó+ô
ð 	
ð ‡{�{”e—k‘kÔ!Ü˜9¨gÖ6Ø	�‰œŸ™Ô	$Ü˜IÖ.Ø	�‰œŸ™Ô	%Ü˜YÖ/ä!Ð$=¸e¿k¹k¸]Ð"KÓLÐLr   )rŽ   r�   rc   rÍ   rÎ   >   éÀ   éÁ   éÂ   éÃ   éÅ   éÆ   éÇ   éÉ   éÊ   éË   éÍ   éÎ   éÏ   )éP   )5Ú__conditional_annotations__Ú
__future__r   ró   rê   rD   rT   Úenumr   Úpathlibr   Útypingr   r   Únumpyr“   rl   Ú	kornia_rsr   r‘   r´   Úkornia.core.checkr	   r
   Úkornia.core.exceptionsr   r   r   Úkornia.image.utilsr   r   rí   r    r"   r7   r:   r;   Ú__annotations__Ú	frozensetr@   rJ   r^   r‰   r¡   r¨   r¯   r»   r-   rÅ   rÒ   rÙ   rÝ   rü   )r  s   @r   Ú<module>r     sê   øð÷$ #Ð "ã Û Û 	Û Ý Ý ß ã Û Ý "ã ß Bß NÑ Nß ?à>Ð õ>ô
�Dô ð. &€õ&ð( €vØ€vØ€vð+Ð ˜ó ñ ÒlÓmÐ õCõ6õD->õ`3 õl!õDõ.hðf #0×"5Ñ"5Ø-2÷>4õB
eõfõg÷bMñ bMr   