
    0-Ph                      2    d Z ddlmZ  G d de          ZdS )aM  Read TIFF from FEI SEM microscopes.

Backend Library: internal

This format is based on :mod:`TIFF <imageio.plugins.tifffile>`, and supports the
same parameters. FEI microscopes append metadata as ASCII text at the end of the
file, which this reader correctly extracts.

Parameters
----------
discard_watermark : bool
    If True (default), discard the bottom rows of the image, which
    contain no image data, only a watermark with metadata.
watermark_height : int
    The height in pixels of the FEI watermark. The default is 70.

See Also
--------
    :mod:`imageio.plugins.tifffile`

   )
TiffFormatc                   >    e Zd ZdZd Z G d dej                  ZdS )FEISEMFormatz!See :mod:`imageio.plugins.feisem`c                     dS )NF )selfrequests     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/imageio/plugins/feisem.py
_can_writezFEISEMFormat._can_write!   s    u    c                   (     e Zd Zd fd	ZddZ xZS )	FEISEMFormat.Reader    TF   c                     t          t          j        |                               |          \  }}|r|d|          }||fS )a"  Get image and metadata from given index.

            FEI images usually (always?) contain a watermark at the
            bottom of the image, 70 pixels high. We discard this by
            default as it does not contain any information not present
            in the metadata.
            N)superr   Reader	_get_data)r   indexdiscard_watermarkwatermark_heightimmeta	__class__s         r
   r   zFEISEMFormat.Reader._get_data%   sN     \0$77AA%HHHB  ,****+t8Or   Nc                    t          | d          r| j        S di i}d}d}| j                                        }t	          |dd          5 }|D ]}|s|                    d          sd}|                                }|                    d	          r.|                    d	                              d
          }i ||<   sd|v rS|                    dd          \  }}	t          t          fD ]}
	  |
|	          }	 n# t          $ r Y w xY w|	||         |<   	 ddd           n# 1 swxY w Y   |d         s%t          |          dk    rt          d|z            || _        |S )a  Read the metadata from an FEI SEM TIFF.

            This metadata is included as ASCII text at the end of the file.

            The index, if provided, is ignored.

            Returns
            -------
            metadata : dict
                Dictionary of metadata.
            	_fei_metarootFutf8ignore)encodingerrorszDate=T[]=r   )maxsplitNz'Input file %s contains no FEI metadata.)hasattrr   r	   get_local_filenameopen
startswithrstriplstripsplitintfloat
ValueErrorlen)r   r   mdcurrent_tagreading_metadatafilenamefinlinekeyvaltag_types              r
   _get_meta_dataz"FEISEMFormat.Reader._get_meta_data2   s    t[)) &~%"B K$|6688HhAAA 7S 7 7D+ 4#w77 4$/3,;;==Ds++ 7&*kk#&6&6&=&=c&B&B*,;$;;'+zz#z'B'BHC-0%L * *!**2(3--C %*E (2 !- !- !-$,H!- 47B{OC0)77 7 7 7 7 7 7 7 7 7 7 7 7 7 7, f: W#b''Q,, !JX!UVVVDNIs7   B$D&0C=;D&=
D
	D&	D
	
D&&D*-D*)r   Tr   )N)__name__
__module____qualname__r   r:   __classcell__)r   s   @r
   r   r   $   sQ        	 	 	 	 	 	-	 -	 -	 -	 -	 -	 -	 -	r   r   N)r;   r<   r=   __doc__r   r   r   r   r   r
   r   r      sV        ++  ; ; ; ; ;" ; ; ; ; ;r   r   N)r?   tifffiler   r   r   r   r
   <module>rA      sa    . !          A A A A A: A A A A Ar   