+
    5is                     $  a  R6 tP0 t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHtHtHtHtHtHtHtHt ^ RIHt ^RIHt ^R	IHtHtHtHt ^R
I H!t! ^RI"H#t#  ^ RI$H%t%H&t&H't'H(t)  ^ RI+H,t, ],PZ                  t.]'       d   ^ RI+H%t0 ^ RI1H2t2 M]t0] ^ k  ^ RI3t3] ! R R4      4       t4]Pj                  ! ]64      t7R7t8]4! 4       t9. ^ N^N^@N^N^ N^N^`N^N^N^N^PN^N^0N^N^pN^N^N^N^HN^N^(N^N^hN^N^N^N^XN^N^8N^N^xN^N^N^N^DN^N^$N^N^dN^N^N^N^TN^N^4N^N^tN^N^N^N^LN^N^,N^N^lN^N^N^N^\N^N^<N^N^|N^N^N^N^BN^N^"N^N^bN^N^N^N^RN^N^2N^N^rN^N^
N^N^JN^N^*N^N^jN^N^N^N^ZN^N^:N^N^zN^N^N^N^FN^N^&N^N^fN^N^N^N^VN^N^6N^N^vN^N^N^N^NN^N^.N^N^nN^N^N^N^^N^N^>N^N^~N^N^N^N^AN^N^!N^N^aN^N^N^N^QN^N^1N^N^qN^N^	N^N^IN^N^)N^N^iN^N^N^N^YN^N^9N^N^yN^N^N^N^EN^N^%N^N^eN^N^N^N^UN^N^5N^N^uN^N^N^N^MN^N^-N^N^mN^N^N^N^]N^N^=N^N^}N^N^N^N^CN^N^#N^N^cN^N^N^N^SN^N^3N^N^sN^N^N^N^KN^N^+N^N^kN^N^N^N^[N^N^;N^N^{N^N^N^N^GN^N^'N^N^gN^N^N^N^WN^N^7N^N^wN^N^N^N^ON^N^/N^N^oN^N^N^N^_N^N^?N^N^N^Nt:Rt;Rt<^	t=^t>R8R R llt?R R lt@R R ltAR R ltBR R ltC]R R l4       tDR  R! ltER9R" R# lltF ! R$ R%4      tGR& R' ltHR( R) ltIR:R* R+ lltJR, R- ltKR. R/ ltLR0 R1 ltMR:R2 R3 lltNR4 R5 ltOR#   ]* d    Rt%Rt&Rt'Rt) ELi ; i  ]*]/3 d    Rt. ELi ; i  ]* d    Rt3 ELi ; i);    N)	dataclass)BytesIO)ceil)Path)	TYPE_CHECKINGAnyBinaryIOIterableOptional	TypeAlias	TypeGuardUnionno_type_check)urlopen)FPDFException)
ImageCacheImageFilterRasterImageInfoVectorImageInfo)	SVGObject)	ImageType)ImageImageCmsTiffImagePluginfeatures)
Resampling)r   )ImageCmsProfilec                   0   a  ] tR t^>t o RtV 3R ltRtV tR# )ImageSettingsc                &   < V ^8  d   Qh/ S[ ;R&   # )   compression_level)int)format__classdict__s   "X/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fpdf/image_parsing.py__annotate__ImageSettings.__annotate__>   s            N)__name__
__module____qualname____firstlineno__r"   __annotate_func____static_attributes____classdictcell__r%   s   @r&   r   r   >   s         r)   r      i  c                    V ^8  d   QhR\         R\        R\        \        \        \        3,          ,          R\        \
        \        \        R\        \        \        R3,          \        \        ,          3,          /# )r!   image_cachenamedimsreturnPILImageN)r   r   r   tuplefloatstrr   r   bytesr	   r   r   r   )r$   s   "r&   r'   r'   n   sn     U" U"U"
U" 5&
'U" 	)Z$
<=o%'	U"r)   c                   \        V\        \        34      '       dK   \        V4      P                  R4      '       d+    \	        \        V4      \        \        V4      4      V R7      # \        V\        4      '       dB   \        VP                  4       4      '       d#   \	        R\        P                  ! V4      V R7      # \        V\        P                  4      '       d;   \        VP                  4       P                  4       4      '       d   \	        RWR7      # \        V\        4      '       d   TRrTEM\        V4      '       dL   VP                  4       p\         P"                  ! RRR7      pVP%                  V4       VP'                  4       TrTM\        V\        \        P                  34      '       d~   \        V\        P                  4      '       d   VP                  4       MTpVP                  4       p\         P"                  ! RRR7      pVP%                  V4       VP'                  4       TrTM\        V4      RrTV P(                  P+                  V4      pVe   VR	,          ^,           VR	&   M\-        VVV P.                  V4      p\1        V P(                  4      ^,           VR
&   ^VR	&   RVR&   VP+                  R4      p	V	ej   \2        P5                  RV4       WP6                  9   d   V P6                  V	,          VR&   M'\1        V P6                  4      p
WP6                  V	&   WR&   RVR&   WP(                  V&   WEV3#   \         d   p\        RT 24      ThRp?ii ; i)a;  
Read an image and load it into memory.

For raster images: following this call, the image is inserted in `image_cache.images`,
and following calls to `fpdf.fpdf.FPDF.image()` will re-use the same cached values, without re-reading the image.

For vector images: the data is loaded and the metadata extracted.

Args:
    image_cache: an `ImageCache` instance, usually the `.image_cache` attribute of a `FPDF` instance.
    name: either a string representing a file path to an image, an URL to an image,
        an io.BytesIO, or a instance of `PIL.Image.Image`.
    dims (tuple[int, int]): optional dimensions as a tuple (width, height) to resize the image
        (raster only) before storing it in the PDF.

Returns: A tuple, consisting of 3 values: the name, the image data,
    and an instance of a subclass of `ImageInfo`.
z.svgr6   zCould not parse file: Nvector_imagemd5F)usedforsecurityusagesiiccp_iiccpzHICC profile found for image %s - It will be inserted in the PDF document)
isinstancer=   r   endswithget_svg_info
load_image	Exception
ValueErrorr>   _is_svgstripior   getvalue_is_pil_imagetobyteshashlibnewupdate	hexdigestimagesgetget_img_infoimage_filterlenLOGGERdebugicc_profiles)r6   r7   r8   errorraster_nameimgbytes_img_hashinforG   rF   s   &&&        r&   preload_imagerf   n   s   8 $d$$T););F)C)C	ID	:c$i0k 
 $74::<#8#8NBJJt,<+VV$

##0E0E0G(H(HNDJJ
 $S	t		;;ue<#--/S	D5"**-	.	.$.tRZZ$@$@d;;ue<#--/St9dS5@5G5G5K5KK5XDh!+X$$	
 **+a/S	XXxxLLZ ///!,!9!9$!?X[55617((.!'XDL*.;'T!!i  	I5dV<=5H	Is   (M M!MM!c                0    V ^8  d   QhR\         R\        /# )r!   rc   r9   )r>   bool)r$   s   "r&   r'   r'      s     G GE Gd Gr)   c                 V    V P                  R 4      ;'       g    V P                  R4      # )s   <?xml s   <svg )
startswith)rc   s   &r&   rN   rN      s&    Y'FF6+<+<X+FFr)   c                F    V ^8  d   QhR\         R\        \        ,          /# )r!   objr9   )r   r   r:   )r$   s   "r&   r'   r'      s     > >s >y2 >r)   c                 V    \         R J;'       d    \        V \         P                   4      # N)r   rH   )rl   s   &r&   rR   rR      s     ==C!==r)   c                \    V ^8  d   QhR\         \        ,          \        ,          R\        /# )r!   filenamer9   )r=   r   r	   )r$   s   "r&   r'   r'      s#     * *th. *8 *r)   c                   \        V \        \        P                  \        34      '       d   V # \        V R4      '       d6   \        V \        \        34      '       g   \        V P                  4       4      # \        V \        4      '       d   \        V 4      p V P                  R4      '       d8   \        V 4      ;_uu_ 4       p\        VP                  4       4      uuRRR4       # V P                  R4      '       d   \        V 4      # \        V R4      ;_uu_ 4       p\        VP                  4       4      uuRRR4       #   + '       g   i     LH; i  + '       g   i     R# ; i)z
This method is used to load external resources, such as images.
It is automatically called when resource added to document by `fpdf.fpdf.FPDF.image()`.
It always return a BytesIO buffer.
readNzdata:rb)zhttp://zhttps://)rH   r   rP   BufferedIOBaser	   hasattrr=   r   rr   rj   r   _decode_base64_imageopen)rp   url_file
local_files   &  r&   rK   rK      s     (Wb&7&7BCCx  HsDk)J)Jx}}''(D!!x=233 X(8==?+ 			W	%	%#H--	h		z() 
		  
		s    D>E>E	E"	c                0    V ^8  d   QhR\         R\        /# )r!   base64Imager9   )r=   r   )r$   s   "r&   r'   r'      s        c  g  r)   c                    V P                  R4      p\        V4      ^8w  d   \        R4      hV^,          p\        P                  ! V4      p\        V4      # )z7Decode the base 64 image string into an io byte stream.zbase64,z!Unsupported non-base64 image data)splitr\   NotImplementedErrorbase64	b64decoder   )r{   frags	imageDatadecodedDatas   &   r&   rv   rv      sM    i(E
5zQ!"EFFaI""9-K;r)   c                R    V ^8  d   QhR\         R\        \        ,          R\        /# )r!   rG   rp   r9   )r>   r=   r   rh   )r$   s   "r&   r'   r'      s%       t  r)   c                D    \         P                  ! \        V 4      4      p\        TP                  P                  4      P                  4       pTR9  d   \        P                  RTT4       R# R#   \         P                   d    \        P                  RT4        R# i ; i)z%Checks the validity of an ICC profilezInvalid ICC Profile in file %sFzEUnsupported color space %s in ICC Profile of file %s - cf. issue #711T)GRAYRGB)
r   getOpenProfiler   
PyCMSErrorr]   re   r=   profilexcolor_spacerO   )rG   rp   r   color_spaces   &&  r&   is_iccp_validr      s    %-%<%<WT]%K goo22399;K/)S	

   4h?s   A0 0+BBc                t    V ^8  d   QhR\         R\        R\        R\        \         \        \
        3,          /# )r!   rp   rb   r6   r9   )r=   r	   r   r;   r   r   )r$   s   "r&   r'   r'     s8       /9
3	?*+r)   c                 B   VP                  ^ 4       VP                  4       p\        W2R7      pVP                  '       d   VP                  w   rVpMR;rgVP                  '       d   VP                  pVP
                  '       d   VP
                  p\        WFVR7      pWV3# )r   r@   g        )datawh)seekrr   r   viewboxwidthheightr   )	rp   rb   r6   svg_datasvg_r   r   re   s	   &&&      r&   rJ   rJ     s~     HHQKxxzH
H
6C
{{{[[
1
yyyII
zzzJJA.D$r)   c                    V ^8  d   QhR\         \        \        \        3,          R\         R\        \        \        \        R3,          R\
        R\        \        \        \        3,          ,          R\        /# )r!   rp   rb   r:   Nr[   r8   r9   )
r   r=   r	   r   r>   r   r   r;   r<   r   )r$   s   "r&   r'   r'     sm     g gC4'(g	z5(D#t;	<g g 5&
'	g
 gr)   c                   \         f   \        R4      hRpRpRpRpV'       d   \        V\        \        34      '       d%   \        V 4      p\         P                  ! V4      pRpMc\        V4      '       gS   \        V\        4      p\        V\        4      '       d   \        V4      pMTpVf   Q h\         P                  ! V4      pRp\        V4      '       g   Q hRpV'       d   VP                  V\        R7      pRpVR8X  dG   VP                  R8X  d   RpM2VP                  R	8X  d    \        P                  ! R
4      '       d   RpMRpVP                  R59   d   VR8w  d   VP!                  R4      pVP                  R69  d   VP!                  R4      pRpVP                  R79   d   VR8X  d   VP!                  R4      pM)VP                  R9   d   VR8X  d   VP!                  R4      pVP"                  w  r\%        4       pRpRVP&                  9   d7   \)        VP&                  R,          V 4      '       d   VP&                  R,          pVEe   V'       Eg   VP                  R8X  d   VR8X  d   VP                  R89   d   ^^RrpMHVP                  R8X  d	   ^^RrpRpM/VP                  R8X  d   ^^RrpM\+        RVP                   24      hVP-                  ^ 4       VP/                  RVP1                  4       RV	RV
RVRVRVR VR!VR"VR#R$V R%V	 2/
4       V# VP                  R&8X  Ed   VR8X  Ed   VP&                  R',          R(8X  Ed   \3        VP4                  \6        P8                  ,          4      ^8X  Edz   \3        VP4                  \6        P:                  ,          4      ^8X  EdJ   VP4                  \6        P<                  ,          pRpV^ 8X  d   RpMV^8w  d   \+        R)V 24      h\?        V4      w  ppVP-                  V4       VP1                  V4      pVP4                  PA                  \6        PB                  4      pVe   V^8X  d   MQV^8X  d=   \E        V4      p\G        V4       F  w  pp\H        V,          VV&   K  	  \        V4      pM\+        R*V 24      h^^RrpVP/                  RVRV	RV
RRRVRVR VR!VR"VR#R+\	        V'       * 4      PK                  4        R%V	 R,V
 2/
4       V# RpVP                  R	8X  d   ^^Rrp\M        W4      VR&   EM;VP                  R8X  d   ^^Rrp\M        W4      VR&   EMVP                  R8X  dM   ^^Rrp\O        ^R^4      p\M        WVR-7      VR&   \Q        V4      '       d   VR99  d   \M        WVR.7      VR/&   EMVP                  R8X  d   ^^R0rp\M        W4      VR&   VPR                  e   VPR                  PR                  MRVR1&   VP&                  PA                  R2R4      e3   VR99  d,   \M        VP!                  R4      V\O        ^R^4      R.7      VR/&   EMVP                  R8X  du   ^^R0rpVPR                  e   VPR                  PR                  MRVR1&   \O        ^R^4      p\M        WVR-7      VR&   \Q        V4      '       d   VR99  d   \M        WVR.7      VR/&   MVP                  R8X  d   ^^Rrp\M        W4      VR&   MoVP                  R8X  d   ^^Rrp\M        W4      VR&   MJ^^Rrp\O        ^R^4      p\M        WVR-7      VR&   \Q        V4      '       d   VR99  d   \M        WVR.7      VR/&   R$V R%V	 2pVP                  R	8X  d	   R3V	 R,V
 2pV'       g'   V'       d   \U        VR4R4       MVPW                  4        VP/                  RV	RV
RVRVR VRVR!VR"VR#V/	4       V# ):z
Args:
    filename: in a format that can be passed to load_image
    img: optional `bytes`, `BytesIO` or `PIL.Image.Image` instance
    image_filter (str): one of the SUPPORTED_IMAGE_FILTERS
Nz1Pillow not available - fpdf2 cannot insert imagesTF)resampleAUTOJPEG	DCTDecode1libtiffCCITTFaxDecodeFlateDecodePPARGBALLAr   CMYK	LZWDecodeicc_profile	DeviceRGB
DeviceCMYK
DeviceGrayzUnsupported image mode: r   r   r   csrG   dpnbpcfinverteddpz/Predictor 15 /Colors z
 /Columns TIFFcompressiongroup4z4unsupported photometric interpretation for g4 tiff: zunsupported FillOrder: z
/BlackIs1 z /K -1 /Rows )remove_slice)select_slicesmaskIndexedpaltransparencyz/BlackIs1 true /Columns fp)r   r   )r   r   r   r   r   r   r   r   )r   r   )r   r   )r   	JPXDecode),r   EnvironmentErrorrH   r   r=   rK   rw   rR   r   r>   resizeRESAMPLEr$   modePIL_featurescheckconvertsizer   re   r   rM   r   rV   rr   r\   tag_v2r   STRIPOFFSETSSTRIPBYTECOUNTSPHOTOMETRIC_INTERPRETATIONccitt_payload_location_from_pilrY   	FILLORDER	bytearray	enumerateTIFFBitRevTablelower_to_dataslice
_has_alphapalettesetattrclose)rp   rb   r[   r8   
is_pil_imgkeep_bytes_io_openjpeg_invertedimg_raw_dataimg_alteredr   r   re   rG   r   r   colspacephotor   offsetlengthccittrawdata	fillorderrE   nalpha_channelr   s   &&&&                      r&   rZ   rZ     s}    }RSSJ M'+L*S4+..!(+jj&
3'W5c5!!"3<LL'''jj&
Kjjj1v::&LXX_!3!3I!>!> ,L(L
xx;<=#@kk&!
xxIIkk&!
xx= \[%@kk% 	d	 ;kk#88DADD -0(;;88M*D::LK$?xx?*%&;((V#%&<( $S%&<(( #;CHH:!FGGa KKL--/(D3323%z!E K JJ&  00'83CJJ;;<=BCJJ>>?@AEJJIIJEHz! J5'R  =SANFFf%.:.?.?.GL

'@'@AI INa(6%l3DAq&5a&8LO 4$\2 #:9+!FGG!"A|hCKKLD3(3Jsx<'8'>'>'@&AA3m\][^_ K L
xx3<(2V	S<(2V	T	<(aq)NVc??| 4
  
 %S]SDM	S9(2V-0[[-Dckk))$U 88<<-9l S
 ?

 %F#\aq@QDM 
T	9(-0[[-Dckk))$Uaq)NVc??| 4
  
 %S]SDM	V	<(2V	U	;(2V;(aq)NVc??| 4
  
 %S]SDM!#j	4B
xx3's-s;Ct$IIKKK(D33"
	
 Kr)   c                   Z   a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltR	tV t	R
# )	temp_attri  zE
temporary change the attribute of an object using a context manager
c                ,   < V ^8  d   QhRS[ RS[RS[ /# )r!   rl   fieldvalue)r   r=   )r$   r%   s   "r&   r'   temp_attr.__annotate__  s"     # #C # #C #r)   c                F    Wn         W n        W0n        R V n        RV n        R# )FN)rl   r   r   exists	old_value)selfrl   r   r   s   &&&&r&   __init__temp_attr.__init__  s    

"r)   c                   < V ^8  d   QhRR/# )r!   r9   Nr*   )r$   r%   s   "r&   r'   r     s     2 24 2r)   c                    \        V P                  V P                  4      '       d-   R V n        \	        V P                  V P                  4      V n        \        V P                  V P                  V P                  4       R# )TN)ru   rl   r   r   getattrr   r   r   )r   s   &r&   	__enter__temp_attr.__enter__  sL    488TZZ((DK$TXXtzz:DN$**djj1r)   c                0   < V ^8  d   QhRS[ RS[ RS[ RR/# )r!   exctypeexcinstexctbr9   N)r   )r$   r%   s   "r&   r'   r     s)     * * *c *# *$ *r)   c                    V P                   '       d.   \        V P                  V P                  V P                  4       R # \        V P                  V P                  4       R # rn   )r   r   rl   r   r   delattr)r   r   r   r   s   &&&&r&   __exit__temp_attr.__exit__  s5    ;;;DHHdjj$..9DHHdjj)r)   )r   r   rl   r   r   N)
r,   r-   r.   r/   __doc__r   r   r   r1   r2   r3   s   @r&   r   r     s(     # #2 2* *r)   r   c                J    V ^8  d   QhRRR\         \        \        3,          /# r!   rb   r:   r9   )r;   r#   )r$   s   "r&   r'   r'     s"       c3h r)   c                    V P                   \        P                  ,          pV P                   \        P                  ,          p\	        V4      ^8w  g   \	        V4      ^8w  d   \        R4      hVVuw  pw  pW43# )zS
returns the byte offset and length of the CCITT payload in the original TIFF data
z;Transcoding multiple strips not supported by the PDF format)r   r   r   r   r\   r~   )rb   strip_offsetsstrip_bytesr   r   s   &    r&   r   r     sw     JJ;;<M**_<<=K 	Ma{q !I
 	

 	 IVy
 >r)   c                (    V ^8  d   QhRRR\         /# r   )r>   )r$   s   "r&   r'   r'   8  s     2! 2!j 2!U 2!r)   c                ^  a aa \        4       p\        P                  ! S P                  S P                  S P                  4       4      pS P                  ^ ,          ^,           ^,          S P                  ^,          ,          o\        \        R4      '       d8   \        \        RS4      ;_uu_ 4        VP                  VRRR7       RRR4       Me\        P                  P                  oR V VV3R llp\        \        P                  RV4      ;_uu_ 4        VP                  VRRR7       RRR4       VP                  ^ 4       \        P                  ! V4      p\        V4      w  rVVP                  V4       VP                  V4      #   + '       g   i     Lf; i  + '       g   i     Ly; i)	zF
Convert the open PIL.Image imgdata to compressed CCITT Group4 data.


STRIP_SIZEr   r   )r$   r   Nc                <    V ^8  d   QhR\         R\        R\        /# )r!   r   tagr9   )r   r#   object)r$   s   "r&   r'   *transcode_monochrome.<locals>.__annotate__V  s&     	D 	Dc 	D 	D 	Dr)   c                    < \         P                  SP                  ^,          \         P                  S.\         P                  ^ ./pVP                  VS! W4      4      # )   )r   ROWSPERSTRIPr   r   r   rY   )r   r  	overridesrb   pillow__getitem__tmp_strip_sizes   && r&   __getitem__)transcode_monochrome.<locals>.__getitem__V  sQ    ,,chhqk//.1A,,qcI
 ==&7&BCCr)   r  )r   r   	frombytesr   r   rS   ru   r   r   saveImageFileDirectory_v2r  r   rw   r   rr   )	rb   newimgioimg2r  newimgr   r   r  r  s	   f      @@r&   transcode_monochromer  8  s7    yH
 ??388SXXs{{}=D hhqkAo!+chhqk9N--nEEIIhv8ID FE
 ,AAMM	D 	D 11=+
 
 IIhv8ID
 MM!ZZ!F4V<NFMM&==  7 FE
 
s   0F	F	F	F,	c                \    V ^8  d   QhRRR\         R,          R\         R,          R\        /# r!   rb   r:   r   Nr   r9   r   r>   )r$   s   "r&   r'   r'   m  s8     =/ =/	=/$,=/ $,=/ 	=/r)   c                 D   \        V P                  4       4      pV'       d   W1 V'       d	   W2,          pV P                  R 8X  d%   \        V P                  ^ ,          ^,          4      pMU\        V4      V P                  ^ ,          V P                  ^,          ,          ,          pV P                  ^ ,          V,          p\        4       p\        ^ \        V4      V4       F-  pVP                  R4       VP                  W7Wt,            4       K/  	  Tp\        .p\        4       w  rrRpV F  pV\        V.4      ,           pW9   d   TpK   VP                  W,          4       V
^\        ,          ^,
          8:  d9   WV&   V
^,          p
W8  d%   V\        8  d   V^,          p^V,          ^,
          pM"VP                  \        4       \        4       w  rr\        V.4      pK  	  V'       d   VP                  W,          4       VP                  \        4       \        V4      # )r       r)   )r   rS   r   r   r   r\   rangeextendLZW_CLEAR_TABLE_MARKERclear_tabler>   appendLZW_MAX_BITS_PER_CODELZW_EOD_MARKERpack_codes_into_bytes)rb   r   r   r   row_sizechannels_countdata_with_paddingrE   result_codestable	next_codebits_per_codemax_code_valuecurrent_sequencebytenext_sequences   &&&             r&   _to_lzwdatar2  m  s   
 S[[]#D!
xx3a(Tsxx{SXXa['@A88A;/!1c$i*  '  !,!78 + D ++L6Am3Em(5$=8!,  78 Q"771<<'0m$Q	--BW2W!Q&M&'=&8A%=N ##$:;BM-?-  %dV}/ 4 E34' ..r)   c                F    V ^8  d   QhR\         \        ,          R\        /# )r!   codesr9   )r
   r#   r>   )r$   s   "r&   r'   r'     s     ( (# (5 (r)   c                d   \        4       w  pppp^ p^ p\        4       p\        e'   \        P                  ! V \        P                  R7      p V  F  pWS,          V,          pWc,          pV^8  d*   V^,          pVP                  WV,	          ^,          4       K0  V\        8X  d   \        4       w  rr4Kd  V\        8w  g   Kq  V^,          pW$8  g   K  V\        8  g   K  V^,          p^V,          ^,
          pK  	  V^ 8  d'   VP                  V^V,
          ,          ^,          4       \        V4      # )z
Convert the list of result codes into a continuous byte stream, with codes packed as per the code bit-width.
The bit-width starts at 9 bits and expands as needed.

)dtype)
r"  r   numpyarrayuint32r#  r!  r%  r$  r>   )	r4  r   r,  r-  r.  bufferbits_in_bufferoutputcodes	   &        r&   r&  r&    s
    		FN[F E6)T1'!aNMM63t;<)):E-7A-^#NI)m>S.S""#}"4!9   v!n"45=>=r)   c                |    V ^8  d   QhR\         \        \        \        3,          \        \        \        3,          /# )r!   r9   )r;   dictr>   r#   )r$   s   "r&   r'   r'     s*     
; 
;U4s
+S#s:; 
;r)   c                     \        R4       U u/ uF  p \        V .4      V bK  	  pp \        ^,           p\        p^V,          ^,
          pWW43# u up i )zC
Reset the encoding table and coding state to initial conditions.

r4   )r  r>   r%  LZW_INITIAL_BITS_PER_CODE)rE   r+  r,  r-  r.  s        r&   r"  r"    sT     %*#J/JqUA3Z]JE/"I-M=(A-N]::	 0s   Ac                @    V ^8  d   QhRRR\         R\        R\        /# )r!   rb   r:   r[   kwargsr9   )r   r   r>   )r$   s   "r&   r'   r'     s.     G G* GK G3 G5 Gr)   c                    VR 8X  d   \        V 3/ VB # VR8X  d   \        V 4      # VR8X  d   \        V 3/ VB # V P                  R8X  d   V P	                  R4      p V P                  R8X  d   V P	                  R4      p VR8X  d.   \        4       pV P                  VRR	7       VP                  4       # VR
8X  d.   \        4       pV P                  VRR	7       VP                  4       # \        RV R24      h)r   r   r   r   r   r   r   r   r   )r$   r   JPEG2000zUnsupported image filter: "")		_to_zdatar  r2  r   r   r   r  rQ   r   )rb   r[   rC  compressed_bytess   &&, r&   r   r     s    }$'''''#C(({"3)&))
xx4kk#
xx6kk% {""9!&1((**{""9!*5((**
5l^1E
FFr)   c                \    V ^8  d   QhRRR\         R,          R\         R,          R\        /# r  r  )r$   s   "r&   r'   r'     s>     N N	N$,N $,N 	Nr)   c                 j   \        V P                  4       4      pV'       d   W1 V'       d	   W2,          pV P                  R 8X  d%   \        V P                  ^ ,          ^,          4      pMU\        V4      V P                  ^ ,          V P                  ^,          ,          ,          pV P                  ^ ,          V,          p\        4       p\        ^ \        V4      V4       F-  pVP                  R4       VP                  W7Wt,            4       K/  	  \        P                  ! V\        P                  R7      # )r   r  )level)r   rS   r   r   r   r\   r  r   zlibcompressSETTINGSr"   )rb   r   r   r   r'  r(  r)  rE   s   &&&     r&   rG  rG    s    
 S[[]#D!
xx3a(Tsxx{SXXa['@A88A;/!1c$i*  '  !,!78 + ==*(2L2LMMr)   c                (    V ^8  d   QhRRR\         /# r   )rh   )r$   s   "r&   r'   r'     s     : :J :4 :r)   c                v   V P                  R4      pVP                  4       w  r#V^8X  d
   V^8X  d   R# W#8X  d   R# \        e(   \        P                  ! V4      ^8g  P	                  4       # \        ;QJ d*    R VP                  4        4       F  '       g   K   R# 	  R# ! R VP                  4        4       4      # )a~  
Return True if the image has any non-opaque alpha channel values.

For the alpha band, `getextrema()` yields the min & max values across all pixels:
- (255, 255): every pixel is fully opaque, so we can fast-return False.
- (x, x) where x != 255: the channel is a flat non-opaque mask, so True.
Otherwise we need to scan for any value different from 255 (using NumPy if available).
AFTc              3   *   "   T F	  q^8g  x  K  	  R# 5i)   Nr*   ).0cs   & r&   	<genexpr>_has_alpha.<locals>.<genexpr>,  s     9!8ACx!8s   )
getchannel
getextremar7  asarrayanyrS   )rb   r   lohis   &   r&   r   r     s     NN3'M%%'FB	SyR3Y	xm,388::39!6!6!893393939!6!6!8999r)   c                @    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r!   r:   )__conditional_annotations__r   )r$   s   "r&   r'   r'      s    f ig r)   )r   r   r   r   r   rn   )Nr   N)NN)Qr_  r   rT   rP   loggingrL  dataclassesr   r   mathr   pathlibr   typingr   r   r	   r
   r   r   r   r   r   urllib.requestr   errorsr   image_datastructuresr   r   r   r   r   r   utilr   PILr   r   r   r   r   ImportError	PIL.Imager   LANCZOSr   AttributeErrorr:   PIL.ImageCmsr   r7  r   	getLoggerr,   r]   SUPPORTED_IMAGE_FILTERSrN  r   r!  r%  rA  r$  rf   rN   rR   rK   rv   r   rJ   rZ   r   r   r  r2  r&  r"  r   rG  r   r'   )r_  s   @r&   <module>rq     s     	   !   
 
 
 # !   NN$!!H +,H
      
 
		8	$X ?
 "&(,.248:>
 "&(,.248:> 	    ! #' )- /3 59 ;? 		 	 	 	 !	 #'	 )-	 /3	 59	 ;?	
 	
 
 
 
 !
 #'
 )-
 /3
 59
 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;? 	    ! #' )- /3 59 ;?  	!  !  !  !  !!  #'!  )-!  /3!  59!  ;?!" 	#" #" #" #" !#" #'#" )-#" /3#" 59#" ;?#$ 	%$ %$ %$ %$ !%$ #'%$ )-%$ /3%$ 59%$ ;?%& 	'& '& '& '& !'& #''& )-'& /3'& 59'& ;?'( 	)( )( )( )( !)( #')( )-)( /3)( 59)( ;?)* 	+* +* +* +* !+* #'+* )-+* /3+* 59+* ;?+, 	-, -, -, -, !-, #'-, )--, /3-, 59-, ;?-. 	/. /. /. /. !/. #'/. )-/. /3/. 59/. ;?/0 	10 10 10 10 !10 #'10 )-10 /310 5910 ;?12 	32 32 32 32 !32 #'32 )-32 /332 5932 ;?34 	54 54 54 54 !54 #'5<    U"pG>*4   $$gT* *2<2!j=/@(V
;G:N2:m  EHOL	 	^$ H  Es6   .M ;M0 )N M-,M-0M?>M?	NN