
    iB                    Z   S r SSKJr  / SQrSSKJrJr  SSKr\(       a  SSKJrJ	r	  SSK
JrJrJr   SSKr S'SS.       S(S	 jjjrSS.S)S
 jjr SSKr S'SS.       S(S jjjrSS.S)S jjr SSKJr   S'SS.       S(S jjjrSS.S)S jjrSS.S*S jjr\  S+SS.         S,S jjj5       r\ S+SS.         S-S jjj5       r  S+SS.         S.S jjjr\          S,S j5       r\          S-S j5       r  S+SS.         S.S jjjr\S/ S.       S/S jj5       r\S/ S.       S0S  jj5       r\S/ S.       S1S! jj5       rS/ S.       S2S" jjr S3SS.           S4S# jjjrSSS$.         S5S% jjr      S6S& jrg! \ a      S'SS.       S(S jjjrSS.S)S jjr GNf = f! \ a      S'SS.       S(S jjjrSS.S)S jjr GNf = f! \ a      S'SS.       S(S jjjrSS.S)S jjr GNf = f)7a   Fallback imagecodecs codecs.

This module provides alternative, pure Python and NumPy implementations of
some functions of the `imagecodecs`_ package. The functions may raise
`NotImplementedError`.

.. _imagecodecs: https://github.com/cgohlke/imagecodecs

    )annotations)bitorder_decodedelta_decodedelta_encodefloat24_decodelzma_decodelzma_encodepackbits_decodepackints_decodepackints_encodezlib_decodezlib_encodezstd_decodezstd_encode)TYPE_CHECKINGoverloadN)AnyLiteral)	ArrayLike	DTypeLikeNDArrayoutc                  AA[        U [        R                  5      (       a  U R                  5       n [        R
                  " U 5      $ )zCompress LZMA.

Parameters:
    data: Data to compress.
    level: Compression level (currently unused).
    out: Output buffer (currently unused).

)
isinstancenumpyndarraytobyteslzmacompressdatalevelr   s      U/var/www/html/banglarbhumi/venv/lib/python3.13/site-packages/tifffile/_imagecodecs.pyr	   r	   H   s4     3dEMM**<<>D}}T""    c              0    A[         R                  " U 5      $ )zeDecompress LZMA.

Parameters:
    data: Compressed data.
    out: Output buffer (currently unused).

)r   
decompressr"   r   s     r$   r   r   \        t$$r%   c                  A AASSK ngRaise ImportError.r   Nr%   r   )r"   r#   r   r   s       r$   r	   r	   i        %r%   c                  A ASSK ngr+   r-   )r"   r   r   s      r$   r   r   v       #r%   c                  A[        U [        R                  5      (       a  U R                  5       n [        R
                  " Xc  S5      $ U5      $ )zCompress Zlib DEFLATE.

Parameters:
    data: Data to compress.
    level: Compression level (0-9, default 6).
    out: Output buffer (currently unused).

   )r   r   r   r   zlibr    r!   s      r$   r   r      s>     dEMM**<<>D}}T1AA5AAr%   c              0    A[         R                  " U 5      $ )zmDecompress Zlib DEFLATE.

Parameters:
    data: Compressed data.
    out: Output buffer (currently unused).

)r3   r'   r(   s     r$   r   r      r)   r%   c                  A AASSK ngr+   r3   )r"   r#   r   r3   s       r$   r   r      r.   r%   c                  A ASSK ngr+   r6   )r"   r   r3   s      r$   r   r      r0   r%   zstdc                  A[        U [        R                  5      (       a  U R                  5       n [        R
                  " XS9$ )zCompress ZSTD.

Parameters:
    data: Data to compress.
    level: Compression level.
    out: Output buffer (currently unused).

)r#   )r   r   r   r   r9   r    r!   s      r$   r   r      s2     dEMM**<<>D}}T//r%   c              0    A[         R                  " U 5      $ )zeDecompress ZSTD.

Parameters:
    data: Compressed data.
    out: Output buffer (currently unused).

)r9   r'   r(   s     r$   r   r      r)   r%   c                  A AASSK Jn  gr,   r   r8   r%   compressionr9   )r"   r#   r   r9   s       r$   r   r      s     %$r%   c                  A ASSK Jn  gr=   r>   )r"   r   r9   s      r$   r   r      s    #$r%   c                  A/ nUR                   nSn  [        XUS-    5      S-   nUS-  nUS:  a  U" XUS-    SU-
  -  5        US-  nOUS:  a  U" XX4-    5        X4-  nMO  ! [         a     Of = f[        U5      $ )a  Decompress PackBits encoded byte string.

Parameters:
    encoded: PackBits encoded byte string.
    out: Output buffer (currently unused).

Returns:
    Decompressed byte string.

Examples:
    >>> packbits_decode(b'\x80\x80')  # NOP
    b''
    >>> packbits_decode(b'\x02123')
    b'123'
    >>> packbits_decode(
    ...     b'\xfe\xaa\x02\x80\x00\x2a\xfd\xaa\x03\x80\x00\x2a\x22\xf7\xaa'
    ... )[:-5]
    b'\xaa\xaa\xaa\x80\x00*\xaa\xaa\xaa\xaa\x80\x00*"\xaa\xaa\xaa\xaa\xaa'

r         i  )extendord	TypeErrorbytes)encodedr   
out_extendins        r$   r
   r
      s    * 	
CJ	AGA&'!+AFA3w7q1u-q9:QS7qu-.   :s   AA# #
A0/A0c                  g N r"   axisdistr   s       r$   r   r     s     r%   c                  g rN   rO   rP   s       r$   r   r   &       r%   c              L   AUS:w  a  SU< S3n[        U5      e[        U [        [        45      (       aa  [        R
                  " U [        R                  S9n [        R                  " U SS9n[        R                  " USU S   5      R                  5       $ U R                  nUR                  S:X  a*  U R                  UR                   SUR                   35      n [        R                  " XS9n[        S	5      /U R                   -  nSXq'   [        R                  " USU [#        U5         US9nU R                  R$                  (       d8  UR'                  S
S9nUR                  UR                  R)                  5       5      nUR                  S:X  a  UR                  U5      $ U$ )a|  Encode Delta.

Encode differences between consecutive samples along axis.

Parameters:
    data: Data to encode.
    axis: Axis along which to compute differences (default -1).
    dist: Distance between samples (only dist=1 is supported).
    out: Output buffer (currently unused).

Returns:
    Encoded data.
    Returns bytes for bytes/bytearray input, numpy array otherwise.

rB   zdelta_encode with dist=# requires the 'imagecodecs' packagedtyper   )rQ   fuNT)inplace)NotImplementedErrorr   rG   	bytearrayr   
frombufferuint8diffinsertr   rX   kindview	byteorderitemsizeslicendimtupleisnativebyteswapnewbyteorder)r"   rQ   rR   r   msgr`   rX   keys           r$   r   r   ,  sV   . 	qy(4')LM!#&&$	*++EKK8zz$Q'||D!T!W-5577JJEzzSyyEOO,Aenn-=>?::d&D#Dk]TYY6CCI<<aeCj!1=D::}}T}*yy0023zzSyyKr%   c                  g rN   rO   rP   s       r$   r   r   [  s     r%   c                  g rN   rO   rP   s       r$   r   r   a  rT   r%   c              &   US:w  a  SU< S3n[        U5      eUb  UR                  R                  (       d  Sn[        U [        [
        45      (       aV  [        R                  " U [        R                  S9n [        R                  " U S[        R                  US9R                  5       $ U R                  R                  S:X  a  U R                  R                  (       d  S	U R                  < S3n[        U5      eU R                  U R                  R                   S
U R                  R                    35      n[        R                  " XQUR                  S9nUR                  U R                  5      $ [        R                  " XU R                  US9$ )a}  Decode Delta.

Decode delta-encoded data by computing cumulative sum along axis.

Parameters:
    data: Encoded data.
    axis: Axis along which to compute cumulative sum (default -1).
    dist: Distance between samples (only dist=1 is supported).
    out: Output buffer for results.

Returns:
    Decoded data.
    Returns bytes for bytes/bytearray input, numpy array otherwise.

rB   zdelta_decode with dist=rV   NrW   r   )rQ   rX   r   rY   zdelta_decode with rZ   )rQ   rX   )r\   flags	writeabler   rG   r]   r   r^   r_   cumsumr   rX   rb   ri   rc   rd   re   )r"   rQ   rR   r   rl   rc   s         r$   r   r   g  s@   . qy(4')LM!#&&
syy22$	*++EKK8||q

')	 zz#zz""$TZZN 35 5  &c**yyDJJ0014::3F3F2GHI||D4::>yy$$<<tzzs r%   )r   	_bitorderc                  g rN   rO   r"   r   rt   s      r$   r   r     s     r%   c                  g rN   rO   rv   s      r$   r   r     s     r%   c                  g rN   rO   rv   s      r$   r   r     s     r%   c                 AU(       dF  UR                  S5        UR                  [        R                  " US   [        R                  S95        [	        U [
        [        45      (       a  U R                  US   5      $  U R                  S5      n[        R                  " US   X3S9  U $ ! [         a  nSn[        U5      UeSnAff = f)	a  Reverse bits in each byte of bytes or numpy array.

Decode data where pixels with lower column values are stored in the
lower-order bits of the bytes (TIFF FillOrder is LSB2MSB).

Parameters:
    data:
        Data to be bit-reversed.
        If bytes type, a new bit-reversed bytes is returned.
        NumPy arrays are bit-reversed in-place.
    out:
        Output buffer (currently unused).
    _bitorder:
        Internal caching parameter (not for public use).

Examples:
    >>> bitorder_decode(b'\x01\x64')
    b'\x80&'
    >>> data = numpy.array([1, 666], dtype='uint16')
    >>> _ = bitorder_decode(data)
    >>> data
    array([  128, 16473], dtype=uint16)

s    @ `P0pH(hX8xD$dT4tL,l\<|B"bR2r
J*jZ:zF&fV6vN.n^>~A!aQ1q	I)iY9yE%eU5uM-m]=}C#cS3sK+k[;{G'gW7wO/o_?r   rW   r_   rB   r   z<bitorder_decode of slices requires the 'imagecodecs' packageN)appendr   r^   r_   r   rG   r]   	translaterc   take
ValueErrorr\   )r"   r   rt   rc   excrl   s         r$   r   r     s    > 	!	
  	)))A,ekkJK$	*++~~il++0yy!

9Q<0 K  0L!#&C/0s   ?)B* *
C4CCc              r   AUS:X  a  [         R                  " U S5      n[         R                  " U5      nUS:  a@  US-  (       a6  UR                  SUSUS-  -
  -   45      nUSS2SU24   R                  S5      nUR	                  U5      $ US;   a  [         R                  " X5      $ SU S	3n[        U5      e)
ab  Decompress bytes to array of integers.

This implementation only handles itemsizes 1, 8, 16, 32, and 64 bits.
Install the Imagecodecs package for decoding other integer sizes.

Parameters:
    data:
        Data to decompress.
    dtype:
        Numpy boolean or integer type.
    bitspersample:
        Number of bits per integer.
    runlen:
        Number of consecutive integers after which to start at next byte.
    out:
        Output buffer (currently unused).

Returns:
    Array of unpacked integers.

Examples:
    >>> packints_decode(b'a', 'B', 1)
    array([0, 1, 1, 0, 0, 0, 0, 1], dtype=uint8)

rB   z|Br      rL   N)r          @   zpackints_decode of z0-bit integers requires the 'imagecodecs' package)r   r^   
unpackbitsreshapeastyper\   )r"   rX   bitspersamplerunlenr   
data_arrayrl   s          r$   r   r     s    D 	%%dD1
%%j1
A:&1*#++R1vz>1J,KLJ#AwwJ/77;J  ''',,
m_ -- 	-  c
""r%   )rQ   r   c                  Sn[        U5      e)zTightly pack integers.

Parameters:
    data: Array of integers to pack.
    bitspersample: Number of bits per integer.
    axis: Axis along which to pack.
    out: Output buffer.

Returns:
    Packed byte string.

z2packints_encode requires the 'imagecodecs' packager\   )r"   r   rQ   r   rl   s        r$   r   r   %  s    ( ?C
c
""r%   c                   Sn[        U5      e)zReturn float32 array from float24.

Parameters:
    data: Bytes containing float24 values.
    byteorder: Byte order, either '>' (big-endian) or '<' (little-endian).

Returns:
    Array of float32 values.

z1float24_decode requires the 'imagecodecs' packager   )r"   rd   rl   s      r$   r   r   =  s     >C
c
""r%   rN   )r#   z
int | Noner"   bytes | NDArray[Any]r   r   returnrG   )r"   rG   r   r   r   rG   )rH   rG   r   r   r   rG   )rL   rB   )
rQ   intrR   r   r"   bytes | bytearrayr   r   r   rG   )
rQ   r   rR   r   r"   NDArray[Any]r   r   r   r   )
rQ   r   rR   r   r"    bytes | bytearray | NDArray[Any]r   r   r   r   )r"   r]   r   r   rt   	list[Any]r   r]   )r"   rG   r   r   rt   r   r   rG   )r"   r   r   r   rt   r   r   r   )r"   r   r   r   rt   r   r   r   )r   )rX   zDTypeLike | Noner   r   r   r   r"   rG   r   r   r   r   )
r"   r   r   r   rQ   r   r   r   r   r   )rd   zLiteral['>', '<']r"   rG   r   r   ) __doc__
__future__r   __all__typingr   r   r   r   r   numpy.typingr   r   r   r   r	   r   ImportErrorr3   r   r   r?   r9   r   r   r
   r   r   r   r   r   r   rO   r%   r$   <module>r      sx  @ #  + #::6
 !#
 # #"#
 # 
#( 37 	%D7
 !B
 B B"B
 B 
B( 37 	%F6 
 !0
 0 0"0
 0 
0( 37 	%D 6: 'T 
 	   	
 
  
 
78HL!$14
BE 
 	, , , 	,
*, 
, ,^ 
&)14
>A
 

 
!$,/
9< 
 	- - - 	-
*- 
- -` 

 
 
	
   
 

 
 
	
   
 

 
 
	
   
 :
*: 
	:
 : &:D 0# 0# 0# 	0#
 0#
0# 
0# 0#p #
##
 # 
# #0#0#
##m  
 !
  "
  
 37  r   !
  "
  
 37  !t  
 !
  "
  
 37  s5    F2  G 5"H 2"GG"H H"H*)H*