+
    ?i.                         R t ^ RIt^ RIt^RIHtHtHt ]P                  ! ]	4      t
Rt ! R R]4      t ! R R]4      tR t ! R R	4      tR# )
z"
PIL formats for multiple images.
N)PillowFormatimage_as_uintndarray_to_pilc                       ] tR t^tRtRtRtR# )
TIFFFormatizTIFF format (Pillow) N)__name__
__module____qualname____firstlineno___modes_description__static_attributes__r       Y/var/www/html/photoedit/myenv/lib/python3.14/site-packages/imageio/plugins/pillowmulti.pyr   r      s    F)Lr   r   c                   L    ] tR t^tRtRtRt ! R R]P                  4      tRt	R# )	GIFFormatz(See :mod:`imageio.plugins.pillow_legacy`iIz Static and animated gif (Pillow)c                   6   a  ] tR t^t o RR ltR tR tRtV tR# )GIFFormat.WriterNc           	        ^ RI Hp \        ;QJ d#    . R VP                  R4       4       F  NK  	  5M! R VP                  R4       4       4      w  rp
V^
8X  d   V	^8  d   \	        RV R24      h\        V4      pV^8  g   VR8  d   \        R4      hVR9  dJ   ^\        \        P                  ! ^4      R,           4      ,          p\        P                  R	V,          4       Vf   R\        V4      ,          V n        MM\        V\        \        34      '       d"   V Uu. uF  p\        V4      NK  	  upV n        M\        V4      V n        \        V4      pV^ 8:  g   V\        R4      8X  d   ^ p\        V4      p\        V4      pV'       d   ^M^V n        V P"                  P%                  4       p\'        WW\        V4      4      V n        R
# u upi )    )__version__c              3   8   "   T F  p\        V4      x  K  	  R # 5iN)int).0xs   & r   	<genexpr>)GIFFormat.Writer._open.<locals>.<genexpr>)   s     'R8Q1A8Qs   .zPillow vz is not supported by ImageIO's legacy pillow plugin when writing GIFs. Consider switching to the new plugin or downgrading to `pillow<10.1.0`.   z!GIF quantize param must be 2..256g+?zDWarning: palettesize (%r) modified to a factor of two between 2-256.Ng      ?inf)                @      r"   )PILr   tuplesplitImportErrorr   
ValueErrornplog2loggerwarningfloat	_duration
isinstancelistbool_disposerequestget_file	GifWriter_writer)selfloopdurationfpspalettesize	quantizersubrectanglespillow_versionmajorminorpatchdfps   &&&&&&&      r   _openGIFFormat.Writer._open   s    :"'%'R8L8LS8Q'R%%'R8L8LS8Q'R"RE%{uz!~. /@ @  k*KQ+"3 !DEE"AA3rwws|e';#<<)+67
 !$uSz!1HtUm444<!=Hq%(H!=!&x;DqyDE%L0t9D /M!.AADM &&(B$4C4DDL ">s   !Gc                :    V P                   P                  4        R # r   )r=   closer>   s   &r   _closeGIFFormat.Writer._closeQ   s    LL r   c                   \        V^R7      pVP                  ^8X  d"   VP                  R,          ^8X  d
   VR,          pV P                  p\	        V\
        4      '       d8   V\        \        V4      ^,
          V P                  P                  4      ,          pV P                  pV P                  P                  WV4       R# )r&   )bitdepthN)NNNrU   r   )r   ndimshaper5   r6   r7   minlenr=   _countr9   	add_image)r>   immetar@   disposes   &&&  r   _append_dataGIFFormat.Writer._append_dataT   s    rA.Bww!| 1[~~H(D))#CH(94<<;N;N$OPmmGLL""29r   )r9   r5   r=   )r   N
   r"   r   F)	r	   r
   r   r   rK   rP   r_   r   __classdictcell____classdict__s   @r   Writerr      s     1	f	!
	 
	r   re   r   N)
r	   r
   r   r   __doc__r   r   r   re   r   r   r   r   r   r      s)    2F5LA$$ A Ar   r   c                 (    V P                  ^RR7      # )r$   little)	byteorder)to_bytes)r   s   &r   intToBinrk   a   s    ::a8:,,r   c                   v   a  ] tR t^et o RtRR ltR tR tR tR t	R t
RR	 ltR
 tRR ltR tRR ltRtV tR# )r<   zClass that for helping write the animated GIF file. This is based on
code from images2gif.py (part of visvis). The version here is modified
to allow streamed writing.
c                    Wn         W n        W0n        W@n        WPn        R V n        R V n        ^ V n        ^ RIH	p W`n	        R # )N)getdata)
rJ   opt_subrectangleopt_loopopt_quantizeropt_palette_size_previous_image_global_paletterZ   PIL.GifImagePluginrn   )r>   filero   rp   rq   rr   rn   s   &&&&&& r   __init__GifWriter.__init__k   s?      0 * 0##.r   c                   TRrTV P                   '       d   V P                  V4      w  rET P                  W@P                  V P                  4      p^ RIHp V! V4      ^ ,          ^,          pV P                  ^ 8X  d#   V P                  WhV P                  4       Wn
        V P                  WhWRV4       Wn        V ;P                  ^,          un        R# )r   )	getheaderNr   r   )ro   getSubRectangleconverToPILrq   rr   ru   rz   rZ   write_headerrp   rt   write_imagers   )	r>   r\   r@   r^   im_rectrectim_pilrz   palettes	   &&&&     r   r[   GifWriter.add_image   s    F    004MG!!'+=+=t?T?TU
 	1F#A&q) ;;!ft}}=#* $'B  "qr   c                    V P                  V4      pV P                  V4      pV P                  P                  V4       V P                  P                  V4       V P                  P                  V4       R # r   )getheaderAnim	getAppExtrJ   write)r>   r\   globalPaletter?   headerappexts   &&&&  r   r~   GifWriter.write_header   sP    ##B'%fm$fr   c                Z    V P                   P                  R P                  R4      4       R# );utf-8N)rJ   r   encoderO   s   &r   rN   GifWriter.close   s    cjj)*r   c                >   V P                   pV P                  V4      pR pV'       d*   \        V4      ^8  d   WP                  ^ 4      ,          pK1  \        V4      ^8X  g   Q hV P	                  W4      p	V P                  WE4      p
W P                  8w  g   V^8w  dF   VP                  V
4       VP                  V	4       VP                  V4       VP                  R4       M"VP                  V
4       VP                  V4       V F  pVP                  V4       K  	  R# )r      N)rJ   rn   rY   popgetImageDescriptorgetGraphicsControlExtrt   r   )r>   r\   r   r   r@   r^   rJ   dataimdeslidgraphextrI   s   &&&&&&      r   r   GifWriter.write_image   s    WW ||Bs5zBXXa[ E5zR %%b/--h@ +++AHHXHHSMHHWHHW HHXHHUO AHHQK r   c                    RpV\        VP                  ^ ,          4      ,          pV\        VP                  ^,          4      ,          pVR,          pV# )z4Get animation header. To replace PILs getheader()[0]s   GIF89as     rk   size)r>   r\   bbs   && r   r   GifWriter.getheaderAnim   sD    
hrwwqz""
hrwwqz""
o	r   Nc                   Vf   RpRpV\        V^ ,          4      ,          pV\        V^,          4      ,          pV\        VP                  ^ ,          4      ,          pV\        VP                  ^,          4      ,          pVR,          pV# )a[  Used for the local color table properties per image.
Otherwise global color table applies to all frames irrespective of
whether additional colors comes in play that require a redefined
palette. Still a maximum of 256 color per frame, obviously.

Written by Ant1 on 2010-08-22
Modified by Alex Robinson in Janurari 2011 to implement subrectangles.
   ,   r{   r   )r>   r\   xyr   s   &&& r   r   GifWriter.getImageDescriptor   s{     :B  	hr!uo
hr!uo
hrwwqz""
hrwwqz"" 	g 	r   c                    V^8X  d   R# V^ 8X  d   RpRpV^ 8w  d0   RpVR,          pVR,          pV\        V4      ,          pVR,          pV# )zlApplication extension. This part specifies the amount of loops.
If loop is 0 or inf, it goes on infinitely.
r   s   !s   NETSCAPE2.0s       i  )rk   )r>   r?   r   s   && r   r   GifWriter.getAppExt   s[     1919D19 B. B+B(4. B'MB	r   c                    RpV\        V^,          ^,          4      P                  R4      ,          pV\        \        V^d,          R,           4      4      ,          pVR,          pVR,          pV# )a  Graphics Control Extension. A sort of header at the start of
each image. Specifies duration and transparancy.

Dispose
-------
  * 0 - No disposal specified.
  * 1 - Do not dispose. The graphic is to be left in place.
  * 2 - Restore to background color. The area used by the graphic
    must be restored to the background color.
  * 3 - Restore to previous. The decoder is required to restore the
    area overwritten by the graphic with what was there prior to
    rendering the graphic.
  * 4-7 -To be defined.
s   !r   g      ?r   )chrr   rk   r   )r>   r@   r^   r   s   &&& r   r   GifWriter.getGraphicsControlExt   sb      
c7Q;1$%,,W55 	hs8c>C/011
g
g	r   c                r   V P                   ^ 8X  d   VR3# V P                  p\        P                  ! W,
          4      pVP                  ^8X  d   VP                  ^4      p\        P                  ! VP                  ^ 4      4      p\        P                  ! VP                  ^4      4      pVP                  '       dh   VP                  '       dV   \        V^ ,          4      \        VR,          ^,           4      rv\        V^ ,          4      \        VR,          ^,           4      rM^ ^rv^ ^rWV	1Wg13,          Wh33# )aJ  Calculate the minimal rectangle that need updating. Returns
a two-element tuple containing the cropped image and an x-y tuple.

Calculating the subrectangles takes extra time, obviously. However,
if the image sizes were reduced, the actual writing of the GIF
goes faster. In some cases applying this method produces a GIF faster.
r{   rT   )	rZ   rs   r0   absrV   sumargwherer   r   )
r>   r\   prevdiffXYx0x1y0y1s
   &&        r   r|   GifWriter.getSubRectangle  s     ;;!v:## vvbi 99>88A;DKK$KK$666afff1YAbEAI1YAbEAIR%,"))r   c                :   \        VR4      pVR9   d3   ^
pVP                  R4      p\        WE4      pVP                  WCR7      pV# VR9   d?   V^8X  d   VP                  R4      pMVP                  R4      pVP                  W2R7      pV# \	        RV,          4      h)	zConvert image to Paletted PIL image.

PIL used to not do a very good job at quantization, but I guess
this has improved a lot (at least in Pillow). I don't think we need
neuqant (and we can add it later if we really want).
gifRGBA)colorsRGB)r   methodzInvalid value for quantizer: %r)nqneuquant)r      r$   )r   convertNeuQuantquantizer/   )r>   r\   rC   palette_sizer   nq_samplefac
nqInstances   &&&&   r   r}   GifWriter.converToPIL9  s      E***L^^F+F!&7J(((EF  )#A~/.__L_KF  >JKKr   )	rZ   rt   rs   rJ   rn   rp   rr   rq   ro   )Tr   r   r"   r   )g?r$   )r"   )r	   r
   r   r   rf   rw   r[   r~   rN   r   r   r   r   r   r|   r}   r   rb   rc   s   @r   r<   r<   e   sH     
.2+B<"4*@ r   r<   )rf   loggingnumpyr0   pillow_legacyr   r   r   	getLoggerr	   r2   r   r   r   rk   r<   r   r   r   <module>r      sY      F F			8	$* *
I IX-m mr   