+
    ?i7                         R t ^ RIHt ^ RIHtHtHtHt ^ RIt^ RI	t
^ RIt^RIHtHtHt ^RIHtHt ^RIHt R R lt ! R	 R
]4      tR# )a  Read/Write TIFF files using tifffile.

.. note::
    To use this plugin you need to have `tifffile
    <https://github.com/cgohlke/tifffile>`_ installed::

        pip install tifffile

This plugin wraps tifffile, a powerful library to manipulate TIFF files. It
superseeds our previous tifffile plugin and aims to expose all the features of
tifffile.

The plugin treats individual TIFF series as ndimages. A series is a sequence of
TIFF pages that, when combined describe a meaningful unit, e.g., a volumetric
image (where each slice is stored on an individual page) or a multi-color
staining picture (where each stain is stored on an individual page). Different
TIFF flavors/variants use series in different ways and, as such, the resulting
reading behavior may vary depending on the program used while creating a
particular TIFF file.

Methods
-------
.. note::
    Check the respective function for a list of supported kwargs and detailed
    documentation.

.. autosummary::
    :toctree:

    TifffilePlugin.read
    TifffilePlugin.iter
    TifffilePlugin.write
    TifffilePlugin.properties
    TifffilePlugin.metadata

Additional methods available inside the :func:`imopen <imageio.v3.imopen>`
context:

.. autosummary::
    :toctree:

    TifffilePlugin.iter_pages

)BytesIO)AnyDictOptionalcastN)	URI_BYTESInitializationErrorRequest)ImagePropertiesPluginV3)	ArrayLikec                f    V ^8  d   QhR\         P                  R\        \        \        3,          /# )   pagereturn)tifffileTiffPager   strr   )formats   "Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/imageio/plugins/tifffile_v3.py__annotate__r   :   s(      (++ S#X     c                    / p V P                   R ,          P                  P                  VR&    T P                   R,          P                  pT P                   R,          P                  pT^ ,          T^,          ,          T^ ,          T^,          ,          3TR&   T#   \         d    Tu # i ; i  \         d     T# \         d     \        P
                  ! R\        4        T# i ; i)i(  resolution_uniti  i  
resolutionzPIgnoring resolution metadata because at least one direction has a 0 denominator.)tagsvalueKeyErrorZeroDivisionErrorwarningswarnRuntimeWarning)r   metadataresolution_xresolution_ys   &   r   _get_resolutionr%   :   s    H&*iin&:&:&@&@"#

yy~++yy~++ Ol1o-Ol1o-"
 O-     O  
	
 O
s/   *B A+B/ B,+B,/C&=C&C&%C&c                      a a ] tR t^Xt oRtV3R lV 3R lltRRRR/V3R lR lltV3R	 lR
 ltRR/V3R lR lltR]	RRRR/V3R lR llt
RRRR/V3R lR lltV3R lV 3R lltRR ltRtVtV ;t# )TifffilePlugina  Support for tifffile as backend.

Parameters
----------
request : iio.Request
    A request object that represents the users intent. It provides a
    standard interface for a plugin to access the various ImageResources.
    Check the docs for details.
kwargs : Any
    Additional kwargs are forwarded to tifffile's constructor, i.e.
    to ``TiffFile`` for reading or ``TiffWriter`` for writing.

c                $   < V ^8  d   QhRS[ RR/# )r   requestr   N)r	   )r   __classdict__s   "r   r   TifffilePlugin.__annotate__g   s     
I 
I 
Id 
Ir   c                t  < \         SV `  V4       R V n        VP                  P                  R8X  d.    \
        P                  ! VP                  4       3/ VB V n        R # \
        P                  ! VP                  4       3/ VB V n        R #   \
        P
                  P                   d    \        R4      hi ; i)Nrz Tifffile can not read this file.)super__init___fhmodeio_moder   TiffFileget_fileTiffFileErrorr   
TiffWriter)selfr)   kwargs	__class__s   &&,r   r/   TifffilePlugin.__init__g   s    !<<3&N#,,W-=-=-?J6J  **7+;+;+=HHDH $$22 N)*LMMNs   *B +B7indexNr   c                @   < V ^8  d   QhRS[ RS[ RS[P                  /# r   r;   r   r   )intnpndarray)r   r*   s   "r   r   r+   w   s&     4 4S 4s 4

 4r   c                  RV9  d   W#R&   MVe   \        R4      hVe   RV9   d   \        R4      hRV9   d   VP                  R4      pMVe   M^ pV\        J d<   Vf8   \        P                  ! V P
                  ! R/ VB  Uu. uF  qDNK  	  up4      pV# V\        J d   RMTpV P                  P                  ! RRV/VB pV# u upi )a#  Read a ndimage or page.

The ndimage returned depends on the value of both ``index`` and
``page``. ``index`` selects the series to read and ``page`` allows
selecting a single page from the selected series. If ``index=None``,
``page`` is understood as a flat index, i.e., the selection ignores
individual series inside the file. If both ``index`` and ``page`` are
``None``, then all the series are read and returned as a batch.

Parameters
----------
index : int
    If ``int``, select the ndimage (series) located at that index inside
    the file and return ``page`` from it. If ``None`` and ``page`` is
    ``int`` read the page located at that (flat) index inside the file.
    If ``None`` and ``page=None``, read all ndimages from the file and
    return them as a batch.
page : int
    If ``None`` return the full selected ndimage. If ``int``, read the
    page at the selected index and return it.
kwargs : Any
    Additional kwargs are forwarded to TiffFile's ``as_array`` method.

Returns
-------
ndarray : np.ndarray
    The decoded ndimage or page.
keyNz,Can't use `page` and `key` at the same time.seriesz0Can't use `series` and `index` at the same time. )
ValueErrorpopEllipsisr?   stackiterr0   asarray)r7   r;   r   r8   xndimages   &$$,  r   readTifffilePlugin.readw   s    <  5MKLL V!3OPPJJx(EEHhh499+>v+>?+>a+>?@G
  "X-D5Ehh&&>e>v>G  @s   
Cc                4   < V ^8  d   QhRS[ P                  /# )r   r   )r?   r@   )r   r*   s   "r   r   r+      s     - -

 -r   c              +  p   "   V P                   P                   F  pVP                  ! R/ VB x  K  	  R# 5i)zYield ndimages from the TIFF.

Parameters
----------
kwargs : Any
    Additional kwargs are forwarded to the TiffPageSeries' ``as_array``
    method.

Yields
------
ndimage : np.ndarray
    A decoded ndimage.
NrD   )r0   rC   rJ   )r7   r8   sequences   &, r   rI   TifffilePlugin.iter   s-      H"",V,, (s   46is_batchFc                <   < V ^8  d   QhRS[ RS[RS[S[,          /# )r   rL   rS   r   )r   boolr   bytes)r   r*   s   "r   r   r+      s)     &# &# &#/3&#	%&#r   c               ~   V'       g   \         P                  ! V4      R,          pV F   pV P                  P                  ! V3/ VB  K"  	  V P                  P
                  \        8X  dS   V P                  P                  4        \        \        V P                  P                  4       4      pVP                  4       # R# )a  Save a ndimage as TIFF.

Parameters
----------
ndimage : ArrayLike
    The ndimage to encode and write to the ImageResource.
is_batch : bool
    If True, the first dimension of the given ndimage is treated as a
    batch dimension and each element will create a new series.
kwargs : Any
    Additional kwargs are forwarded to TiffWriter's ``write`` method.

Returns
-------
encoded_image : bytes
    If the ImageResource is ``"<bytes>"``, return the encoded bytes.
    Otherwise write returns None.

Notes
-----
Incremental writing is supported. Subsequent calls to ``write`` will
create new series unless ``contiguous=True`` is used, in which case the
call to write will append to the current series.

N)N:NNN)r?   rJ   r0   write_request	_uri_typer   closer   r   r4   getvalue)r7   rL   rS   r8   imagefiles   &&$,  r   rX   TifffilePlugin.write   s    : jj)'2GEHHNN5+F+  ==""i/HHNN!7!7!9:D==?" 0r   exclude_appliedTc          
      H   < V ^8  d   QhRS[ RS[ RS[RS[S[S[3,          /# )r   r;   r   r`   r   )r>   rU   r   r   r   )r   r*   s   "r   r   r+      s;     L LL.1LKOL	c3hLr   c                  V\         Jd4   Ve0   V P                  P                  V,          P                  V,          pMkV\         Jd4   Vf0   V P                  P                  V,          P                  ^ ,          pM.V\         J d#   Ve   V P                  P                  V,          pMRp/ pVf   V P                  P                  VR&   \
        P                  P                   F  p\        V P                  RV,           4      pWuRV,           &   V'       g   K5  \        V P                  VR,           4      '       g   KZ  \        V P                  VR,           4      p\        V\        4      '       d   VP                  V^ ,          4       K  VP                  V4       K  	  V# VP                  pTP                  VP                   U	u/ uF  qP                  V	P                   bK  	  up	4       VP                  RVP"                  RVP$                  RVP&                  RRR	VP(                  R
VP*                  RVP,                  /\/        V4      CRVP0                  /C4       V# u up	i )a  Format-Specific TIFF metadata.

The metadata returned depends on the value of both ``index`` and
``page``. ``index`` selects a series and ``page`` allows selecting a
single page from the selected series. If ``index=Ellipsis``, ``page`` is
understood as a flat index, i.e., the selection ignores individual
series inside the file. If ``index=Ellipsis`` and ``page=None`` then
global (file-level) metadata is returned.

Parameters
----------
index : int
    Select the series of which to extract metadata from. If Ellipsis, treat
    page as a flat index into the file's pages.
page : int
    If not None, select the page of which to extract metadata from. If
    None, read series-level metadata or, if ``index=...`` global,
    file-level metadata.
exclude_applied : bool
    For API compatibility. Currently ignored.

Returns
-------
metadata : dict
    A dictionary with information regarding the tiff flavor (file-level)
    or tiff tags (page-level).
N	byteorderis_	_metadataplanar_configurationcompression	predictororientationdescription1descriptionsoftwaredatetime)rG   r0   rC   pagesrc   r   TIFF
FILE_FLAGSgetattrhasattr
isinstancetupleupdatekeyframer   namer   planarconfigrg   rh   rj   rk   rl   r%   rm   )
r7   r;   r   r`   targetr"   flag
flag_valueflavor_metadatatags
   &$$$      r   r"   TifffilePlugin.metadata   s   >  T%5XX__U+11$7F("t| XX__U+11!4Fh4#3XX^^D)FF>$(HH$6$6H[! 00$TXXut|<
)3&:'$((D;4F"G"G&-dhh{8J&KO!/599 (:; 8 1: # __FOOFKKHKSXXsyy0KHIOO*F,?,?!6#5#5!1!1!4"F$7$7!6#5#5
 &f-
 
  Is   I!c                ,   < V ^8  d   QhRS[ RS[ RS[/# r=   )r>   r
   )r   r*   s   "r   r   r+   5  s'     A A3 AS AO Ar   c          	     *   T;'       g    ^ pVR\         39   d   ^ MTpV\         J d   V P                  P                  V,          pM.V P                  P                  V,          P                  V,          pV\         J df   Vfb   \	        V P                  P                  4      p\        V.VP                  O5VP                  VR\        V4      P                  R4      R7      pV# V\         J dl   V\         J db   \	        V P                  P                  4      p\        V.VP                  O5VP                  VR\        V4      P                  R4      R7      pV# \        VP                  VP                  R\        V4      P                  R4      R7      pV# )a  Standardized metadata.

The properties returned depend on the value of both ``index`` and
``page``. ``index`` selects a series and ``page`` allows selecting a
single page from the selected series. If ``index=Ellipsis``, ``page`` is
understood as a flat index, i.e., the selection ignores individual
series inside the file. If ``index=Ellipsis`` and ``page=None`` then
global (file-level) properties are returned. If ``index=Ellipsis``
and ``page=...``, file-level properties for the flattened index are
returned.

Parameters
----------
index : int
    If ``int``, select the ndimage (series) located at that index inside
    the file. If ``Ellipsis`` and ``page`` is ``int`` extract the
    properties of the page located at that (flat) index inside the file.
    If ``Ellipsis`` and ``page=None``, return the properties for the
    batch of all ndimages in the file.
page : int
    If ``None`` return the properties of the full ndimage. If ``...``
    return the properties of the flattened index. If ``int``,
    return the properties of the page at the selected index only.

Returns
-------
image_properties : ImageProperties
    The standardized metadata (properties) of the selected ndimage or series.

NTr   )shapedtypen_imagesrS   spacingF)r   r   rS   r   )
rG   r0   rn   rC   lenr
   r   r   r%   get)r7   r;   r   page_idxtarget_pagen_seriespropsn_pagess   &$$     r   
propertiesTifffilePlugin.properties5  s]   > 

x 001dH((..2K((//%066x@KH488??+H#4+"3"34!''!'488FE0 # h48#3$((..)G#3!2!23!'' '488FE  $!''!'''488F	E r   c                   < V ^8  d   QhRR/# )r   r   NrD   )r   r*   s   "r   r   r+   x  s      t r   c                t   < V P                   e   V P                   P                  4        \        SV `  4        R # )N)r0   r[   r.   )r7   r9   s   &r   r[   TifffilePlugin.closex  s$    88HHNNr   c              +     "   V\         J d   V P                  P                  pMV P                  P                  V,          pV F  pVP                  ! R/ VB x  K  	  R# 5i)a  Yield pages from a TIFF file.

This generator walks over the flat index of the pages inside an
ImageResource and yields them in order.

Parameters
----------
index : int
    The index of the series to yield pages from. If Ellipsis, walk over
    the file's flat index (and ignore individual series).
kwargs : Any
    Additional kwargs are passed to TiffPage's ``as_array`` method.

Yields
------
page : np.ndarray
    A page stored inside the TIFF file.

NrD   )rG   r0   rn   rC   rJ   )r7   r;   r8   rn   r   s   &&,  r   
iter_pagesTifffilePlugin.iter_pages  sJ     * HHHNNEHHOOE*ED,,((( s   AA )r0   ).)__name__
__module____qualname____firstlineno____doc__r/   rM   rI   rX   rG   r"   r   r[   r   __static_attributes____classdictcell____classcell__)r9   r*   s   @@r   r'   r'   X   s     
I 
I 44 4T 4 4l- -$&#6;&# &#PL&L48LRVL L\A A4 A AF ) )r   r'   )r   ior   typingr   r   r   r   r   numpyr?   r   core.requestr   r   r	   core.v3_plugin_apir
   r   r   r%   r'   rD   r   r   <module>r      s>   +Z  , ,    B B : <E)X E)r   