Ë
    Eü´j;  ã                   ó†   — d Z ddlmZmZmZmZmZmZmZ ddl	Z	ddl
ZddlmZmZmZmZ ddlmZmZ ddlmZ  G d„ d	e«      Zy)
z´Read/Write images using rawpy.

rawpy is an easy-to-use Python wrapper for the LibRaw library.
It also contains some extra functionality for finding and repairing hot/dead pixels.
é    )ÚAnyÚDictÚIteratorÚListÚOptionalÚTupleÚUnionNé   )Ú	URI_BYTESÚInitializationErrorÚIOModeÚRequest)ÚImagePropertiesÚPluginV3)Ú	ArrayLikec            	       óÞ   ‡ — e Zd ZdZdeddfˆ fd„Zdd„Zddœd	edej                  fd
„Z
deeee   f   dee   fd„Zdeej                     fd„Z	 dd	ededeeef   fd„Zdd	edefd„Zˆ xZS )ÚRawPyPluginz�A class representing the rawpy plugin.

    Methods
    -------

    .. autosummary::
    :toctree: _plugins/rawpy

    RawPyPlugin.read
    ÚrequestÚreturnNc                 ó  •— t         ‰| �  |«       d| _        |j                  j                  t
        j                  k(  r*	 t        j                  |j                  «       «      | _        y|j                  j                  t
        j"                  k(  rt        d«      d‚y# t        j                  t        j                  t        j                  f$ r: |j                  t        k(  rt        d«      d‚t        d|j                   › d�«      d‚w xY w)z¹Instantiates a new rawpy plugin object

        Parameters
        ----------
        request: Request
            A request object representing the resource to be operated on.
        Nz&RawPy can not read the provided bytes.zRawPy can not read ú.úRawPy does not support writing.)ÚsuperÚ__init__Ú_image_fileÚmodeÚio_moder   ÚreadÚrawpyÚimreadÚget_fileÚNotSupportedErrorÚLibRawFileUnsupportedErrorÚLibRawIOErrorÚ	_uri_typer   r   Úraw_uriÚwrite)Úselfr   Ú	__class__s     €úS/root/workspace/ytshorts/venv/lib/python3.12/site-packages/imageio/plugins/rawpy.pyr   zRawPyPlugin.__init__   sî   ø€ ô 	‰Ñ˜Ô!àˆÔà�<‰<×Ñ¤6§;¡;Ò.ð Ü#(§<¡<°×0@Ñ0@Ó0BÓ#C�Õ ð �\‰\×!Ñ!¤V§\¡\Ò1Ü%Ð&GÓHÈdÐRð 2øô ×'Ñ'Ü×0Ñ0Ü×#Ñ#ðò  ð
 ×$Ñ$¬	Ò1Ü-Ø@óàð ô .Ø-¨g¯o©oÐ->¸aÐ@óàð ð ús   Á (B ÂA,D	c                 ó„   — | j                   r| j                   j                  «        | j                  j                  «        y ©N)r   ÚcloseÚ_requestÚfinish©r(   s    r*   r-   zRawPyPlugin.close<   s-   € Ø×ÒØ×Ñ×"Ñ"Ô$à�‰×ÑÕó    r   )Úindexr2   c                óx   — 	  | j                   j                  di |¤Ž}|t        u rd   }S # t        $ r Y Œw xY w)znRead Raw Image.

        Returns
        -------
        nd_image: ndarray
            The image data
        )N.© )r   ÚpostprocessÚ	ExceptionÚEllipsis)r(   r2   ÚkwargsÚnd_images       r*   r   zRawPyPlugin.readB   sO   € ð	Ø3�t×'Ñ'×3Ñ3Ñ=°fÑ=ˆHð ”HÑØ 	Ñ*ˆHàˆøô ò 	Ùð	ús   ‚- ­	9¸9Úndimagec                 ó   — t        «       ‚)r   )ÚNotImplementedError)r(   r:   s     r*   r'   zRawPyPlugin.writeW   s   € ä!Ó#Ð#r1   c              #   óP   K  — 	 | j                  «       –— y# t        $ r Y yw xY w­w)znLoad the image.

        Returns
        -------
        nd_image: ndarray
            The image data
        N)r   r6   r0   s    r*   ÚiterzRawPyPlugin.iter[   s(   è ø€ ð	Ø—)‘)“+ÓøÜò 	Ùð	üs   ‚&„ –&—	# &¢#£&Úexclude_appliedc                 ód  — i }| j                   j                  }| j                   j                  |d<   | j                   j                  |d<   | j                   j                  |d<   | j                   j
                  |d<   | j                   j                  |d<   | j                   j                  j                  |d<   |j                  |d<   | j                   j                  |d<   | j                   j                  |d	<   |j                  |d
<   |j                  |d<   |j                  |d<   |j                  |d<   | j                   j                  j                   |d<   |j"                  |d<   |j$                  |d<   |j&                  |d<   | j                   j(                  |d<   |�r|j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  d	d«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |j+                  dd«       |S )aõ  Read ndimage metadata.

        Parameters
        ----------
        exclude_applied : bool
            If True, exclude metadata fields that are applied to the image while
            reading. For example, if the binary data contains a rotation flag,
            the image is rotated by default and the rotation flag is excluded
            from the metadata to avoid confusion.

        Returns
        -------
        metadata : dict
            A dictionary of format-specific metadata.

        Úblack_level_per_channelÚcamera_white_level_per_channelÚ
color_descÚcolor_matrixÚdaylight_whitebalanceÚdtypeÚflipÚ
num_colorsÚ
tone_curveÚwidthÚheightÚ	raw_widthÚ
raw_heightÚ	raw_shapeÚiwidthÚiheightÚpixel_aspectÚwhite_levelN)r   ÚsizesrA   rB   rC   rD   rE   Ú	raw_imagerF   rG   rH   rI   rJ   rK   rL   rM   ÚshaperO   rP   rQ   rR   Úpop)r(   r2   r?   ÚmetadataÚ
image_sizes        r*   rW   zRawPyPlugin.metadatai   se  € ð( ˆà×%Ñ%×+Ñ+ˆ
à.2×.>Ñ.>×.VÑ.VˆÐ*Ñ+à×Ñ×;Ñ;ð 	Ð1Ñ2ð "&×!1Ñ!1×!<Ñ!<ˆ�ÑØ#'×#3Ñ#3×#@Ñ#@ˆ�Ñ Ø,0×,<Ñ,<×,RÑ,RˆÐ(Ñ)Ø ×,Ñ,×6Ñ6×<Ñ<ˆ�ÑØ%Ÿ?™?ˆ�ÑØ!%×!1Ñ!1×!<Ñ!<ˆ�ÑØ!%×!1Ñ!1×!<Ñ!<ˆ�ÑØ&×,Ñ,ˆ�ÑØ'×.Ñ.ˆ�ÑØ *× 4Ñ 4ˆ�ÑØ!+×!6Ñ!6ˆ�ÑØ $× 0Ñ 0× :Ñ :× @Ñ @ˆ�ÑØ'×.Ñ.ˆ�ÑØ(×0Ñ0ˆ�ÑØ#-×#:Ñ#:ˆ�Ñ Ø"&×"2Ñ"2×">Ñ">ˆ�ÑâØ�L‰LÐ2°DÔ9Ø�L‰LÐ9¸4Ô@Ø�L‰L˜ tÔ,Ø�L‰L˜¨Ô.Ø�L‰LÐ0°$Ô7Ø�L‰L˜ $Ô'Ø�L‰L˜ Ô&Ø�L‰L˜ tÔ,Ø�L‰L˜ tÔ,Ø�L‰L˜ dÔ+Ø�L‰L˜ tÔ,Ø�L‰L˜ dÔ+Ø�L‰L˜ 4Ô(Ø�L‰L˜ DÔ)Ø�L‰L˜¨Ô-àˆr1   c                 óÀ   — | j                   j                  }|j                  }|j                  }||f}| j                   j                  j
                  }t        ||¬«      S )a  Standardized ndimage metadata

        Returns
        -------
        properties : ImageProperties
            A dataclass filled with standardized image metadata.

        Notes
        -----
        This does not decode pixel data and is fast for large images.

        )rU   rF   )r   rS   rJ   rK   rT   rF   r   )r(   r2   Ú	ImageSizerJ   rK   rU   rF   s          r*   Ú
propertieszRawPyPlugin.properties©   sV   € ð ×$Ñ$×*Ñ*ˆ	à—_‘_ˆØ×&Ñ&ˆØ"(¨% ˆà× Ñ ×*Ñ*×0Ñ0ˆä U°%Ô8Ð8r1   )r   N)NTr,   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r-   ÚintÚnpÚndarrayr   r	   r   r   r   Úbytesr'   r   r>   Úboolr   Ústrr   rW   r   r[   Ú__classcell__)r)   s   @r*   r   r      s¸   ø„ ñ	ðS ð S¨Dõ Só@ð $%ò ˜Sð °2·:±:ó ð*$˜U 9¨d°9©oÐ#=Ñ>ð $À8ÈEÁ?ó $ð�h˜rŸz™zÑ*ó ð :>ñ>Øð>Ø26ð>à	ˆc�3ˆh‰ó>ñ@9 ð 9¨÷ 9r1   r   )r_   Útypingr   r   r   r   r   r   r	   r   Únumpyra   Úcore.requestr   r   r   r   Úcore.v3_plugin_apir   r   r   r   r4   r1   r*   ú<module>rk      s6   ðñ÷ E× DÑ DÛ Û ç JÓ Jß :Ý ôo9�(õ o9r1   