
    ⨽g<                         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 )RawPyPluginzA 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)zInstantiates 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     ^/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/imageio/plugins/rawpy.pyr   zRawPyPlugin.__init__   s     	!<<6;;. #(<<0@0@0B#C  \\!!V\\1%&GHdR 2 ''00##  
 $$	1-@  .-goo->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    	3t''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">">LL2D9LL94@LLt,LL.LL0$7LL$'LL&LLt,LLt,LLd+LLt,LLd+LL4(LLD)LL-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:: *$U9d9o#=> $8E? $hrzz*  :>>>26>	c3h>@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   