
    9i;                         S r SSKJrJrJrJrJrJrJr  SSK	r	SSK
rSSKJrJrJrJr  SSKJrJr  SSKJr   " S S	\5      rg)
zRead/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            	          ^  \ rS rSrSrS\SS4U 4S jjrSS jrSS	.S
\S\	R                  4S jjrS\\\\   4   S\\   4S jrS\\	R                     4S jr SS
\S\S\\\4   4S jjrSS
\S\4S jjrSrU =r$ )RawPyPlugin   zuA class representing the rawpy plugin.

Methods
-------

.. autosummary::
:toctree: _plugins/rawpy

RawPyPlugin.read
requestreturnNc                 "  > [         TU ]  U5        SU l        UR                  R                  [
        R                  :X  a+   [        R                  " UR                  5       5      U l        gUR                  R                  [
        R"                  :X  a  [        S5      Seg! [        R                  [        R                  [        R                  4 a;    UR                  [        :X  a  [        S5      Se[        SUR                    S35      Sef = f)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     U/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/imageio/plugins/rawpy.pyr   RawPyPlugin.__init__   s     	!<<6;;. #(<<0@0@0B#C  \\!!V\\1%&GHdR 2 ''00##  
 $$	1-@  .-goo->a@  s   )B   A.Dc                     U R                   (       a  U R                   R                  5         U R                  R                  5         g N)r   close_requestfinishr)   s    r+   r/   RawPyPlugin.close<   s-    ""$    r   )indexr5   c                |     U R                   R                  " S0 UD6nU[        L a  WS   nW$ ! [         a     Nf = f)zFRead Raw Image.

Returns
-------
nd_image: ndarray
    The image data
)N. )r   postprocess	ExceptionEllipsis)r)   r5   kwargsnd_images       r+   r   RawPyPlugin.readB   sM    	''33=f=H H	*H  		s   . 
;;ndimagec                     [        5       e)r   )NotImplementedError)r)   r>   s     r+   r(   RawPyPlugin.writeW   s    !##r4   c              #   R   #     U R                  5       v   g! [         a     gf = f7f)zFLoad the image.

Returns
-------
nd_image: ndarray
    The image data
N)r   r9   r2   s    r+   iterRawPyPlugin.iter[   s'     	))+ 		s   ' '
$'$'exclude_appliedc                 n   0 nU R                   R                  nU R                   R                  US'   U R                   R                  US'   U R                   R                  US'   U R                   R
                  US'   U R                   R                  US'   U R                   R                  R                  US'   UR                  US'   U R                   R                  US'   U R                   R                  US	'   UR                  US
'   UR                  US'   UR                  US'   UR                  US'   U R                   R                  R                   US'   UR"                  US'   UR$                  US'   UR&                  US'   U R                   R(                  US'   U(       Ga  UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  S	S5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        UR+                  SS5        U$ )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   sizesrG   rH   rI   rJ   rK   	raw_imagerL   rM   rN   rO   rP   rQ   rR   rS   shaperU   rV   rW   rX   pop)r)   r5   rE   metadata
image_sizes        r+   r]   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-r4   c                     U R                   R                  nUR                  nUR                  nXC4nU R                   R                  R
                  n[        XVS9$ )zStandardized 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.

)r[   rL   )r   rY   rP   rQ   rZ   rL   r   )r)   r5   	ImageSizerP   rQ   r[   rL   s          r+   
propertiesRawPyPlugin.properties   sR     $$**	__&&"(  **00U88r4   )r   )r   N)NTr.   )__name__
__module____qualname____firstlineno____doc__r   r   r/   intnpndarrayr   r	   r   r   r   bytesr(   r   rC   boolr   strr   r]   r   rb   __static_attributes____classcell__)r*   s   @r+   r   r      s    	S SD S@ $% S 2:: *$U9d9o#=> $8E? $hrzz*  :>>>26>	c3h>@9 9 9 9r4   r   )rh   typingr   r   r   r   r   r   r	   r    numpyrj   core.requestr   r   r   r   core.v3_plugin_apir   r   r   r   r7   r4   r+   <module>ru      s6    E D D   J J : o9( o9r4   