o
    4ήc                     @  sf   d Z ddlmZ ddgZddlmZ ddlmZ ddlm	Z	 ddl
Z
G d	d de	Zedfd
dZdS )z%TIFF codec for the Numcodecs package.    )annotationsregister_codecTiff)BytesIO)registry)CodecNc                   @  sZ   e Zd ZdZdZdddddddddddddddddi dddfddZdd	 Zdd
dZdS )r   zTIFF codec for Numcodecs.tifffileNF c                 C  s   || _ || _|| _|| _|| _|| _|| _|| _|	| _|
| _	|| _
|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _d S N)keyserieslevelbigtiff	byteorderimagejomephotometricplanarconfigextrasamples
volumetrictilerowsperstripcompressioncompressionargs	predictorsubsamplingmetadata	extratagstruncate
maxworkers)selfr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r	   9/tmp/pip-target-vg8gfxp4/lib/python/tifffile/numcodecs.py__init__3   s*   
zTiff.__init__c                 C  s   t  M}tj|| j| j| j| jd*}|j|| j| j	| j
| j| j| j| j| j| j| j| j| j| j| jd W d   n1 s?w   Y  | }W d   |S 1 sSw   Y  |S )zReturn TIFF file as bytes.)r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   N)r   r   
TiffWriterr   r   r   r   writer   r   r   r   r   r   r   r   r   r   r   r   r   r   getvalue)r    buffhtifresultr	   r	   r!   encoded   s@   

zTiff.encodec              	   C  s   t |4}t|}|j| j| j| j| j|d}W d   n1 s#w   Y  W d   |S W d   |S 1 s;w   Y  |S )z$Return decoded image as NumPy array.)r   r   r   r   outN)r   r   TiffFileasarrayr   r   r   r   )r    r&   r+   r'   r(   r)   r	   r	   r!   decode   s"   

	
		zTiff.decoder
   )__name__
__module____qualname____doc__codec_idr"   r*   r.   r	   r	   r	   r!   r   .   s6    
1c                 C  s   t j| |d dS )z/Register :py:class:`Tiff` codec with Numcodecs.)r3   N)r   r   )clsr3   r	   r	   r!   r      s   )r2   
__future__r   __all__ior   	numcodecsr   numcodecs.abcr   r   r   r   r	   r	   r	   r!   <module>   s   b