o
    h                      @   s$   d Z ddlmZ G d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                   @   s*   e Zd ZdZdd ZG dd dejZdS )FEISEMFormatz!See :mod:`imageio.plugins.feisem`c                 C   s   dS )NF )selfrequestr   r   Q/var/www/html/scripts/venv/lib/python3.10/site-packages/imageio/plugins/feisem.py
_can_write!   s   zFEISEMFormat._can_writec                       s(   e Zd Zd	 fdd	Zd
ddZ  ZS )zFEISEMFormat.Reader    TF   c                    s0   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__r   r   r   %   s   zFEISEMFormat.Reader._get_dataNc                 C   s   t | dr| jS di i}d}d}| j }t|dddW}|D ]L}|s+|ds)qd}| }|d	rA|d	d
}i ||< qd|v rk|jddd\}}	t	t
fD ]}
z|
|	}	W n	 tyc   Y qRw  |	|| |< qW d   n1 svw   Y  |d st|dkrtd| || _|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_typer   r   r   _get_meta_data2   sB   




z"FEISEMFormat.Reader._get_meta_data)r	   Tr
   )N)__name__
__module____qualname__r   r3   __classcell__r   r   r   r   r   $   s    r   N)r4   r5   r6   __doc__r   r   r   r   r   r   r   r      s    r   N)r8   tifffiler   r   r   r   r   r   <module>   s   