Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/PIL/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/PIL/__pycache__/GifImagePlugin.cpython-310.pyc
o

��!j4��@snddlZddlZddlZddlZddlmZmZmZmZm	Z	ddl
mZddl
m
Z
ddl
mZdd�ZGd	d
�d
ej�Zdddd
�Zd6dd�Zdd�Zdd�Zdd�Zdd�Zd6dd�Zdd�Zdd�Zdd �ZdZd!d"�Zd#d$�Zd%d&�Zd'd(�Z d)d*�Z!d+d,�Z"d-d.�Z#d7d/d0�Z$d8d2d3�Z%e�&ej'ee�e�(ej'e�e�)ej'e�e�*ej'd4�e�+ej'd5�dS)9�N�)�Image�
ImageChops�	ImageFile�ImagePalette�
ImageSequence)�i16le)�o8)�o16lecCs|dd�dvS)N�)sGIF87asGIF89a�)�prefixrr�4/usr/lib/python3/dist-packages/PIL/GifImagePlugin.py�_accept)�rcs|eZdZdZdZdZdZdd�Zdd�Ze	d	d
��Z
e	dd��Zd
d�Zdd�Z
�fdd�Zdd�Zdd�Zdd�Z�ZS)�GifImageFile�GIFzCompuserve GIFFNcCs,|j�d�}|r|dr|j�|d�SdS)Nrr)�fp�read)�self�srrr�data:szGifImageFile.datacCs|j�d�}t|�std��|dd�|jd<t|d�t|d�f|_g|_|d}|d@d}|d	@rw|d
|jd<|j�d|>�}td
t	|�d�D],}|d||krg||dkrg||dksvnt
�d|�}||_|_
nqJ|j|_|j��|_d|_d|_|�d
�dS)N�
znot a GIF filer�version��
�r���
background�r��RGB)rrr�SyntaxError�info�i16�_size�tile�range�lenr�raw�global_palette�palette�_GifImageFile__fp�tell�_GifImageFile__rewind�	_n_frames�_is_animated�_seek)rr�flags�bits�p�irrr�_open@s,8�zGifImageFile._opencCsZ|jdur*|��}z	|�|��d�qty$|��d|_Ynw|�|�|jS)NTr)r0r.�seek�EOFError�r�currentrrr�n_frames^s
��
zGifImageFile.n_framescCsl|jdur3|jdur|jdk|_|jS|��}z
|�d�d|_Wnty-d|_Ynw|�|�|jS)NrTF)r1r0r.r8r9r:rrr�is_animatedjs

�


�
zGifImageFile.is_animatedcCs�|�|�sdS||jkrd|_|�d�|j}t|jd|d�D]}z|�|�Wq!ty@}z
|�|�td�|�d}~wwdS)Nrrzno more images in GIF file)�_seek_check�_GifImageFile__frame�imr2r(r9r8)r�frame�
last_frame�f�errrr8{s




���zGifImageFile.seekcs�|dkrd|_d|_gd�|_d|_|j�|j�d|_n|jr$|�	�||jdkr2t
d|����g|_|j|_|jrO|j�|j�|��rL	|��sGd|_d}i}d}d}d}	|j�
d�}|rf|dkrh�n|dkr�|j�
d�}|��}|dd	kr�|d}	|	d@r�|d
}t|d�d|d<d
|	@}
|
d?}
|
r�|
|_nN|ddkr�|r�d|vr�|d|7<n||d<|��}|s�qY|ddkr�||j��f|d<|dd�dkr�|��}t|�d
kr�|ddkr�t|d�|d<|��r�	|��s�n�|dk�ry|j�
d�}t|d�t|d�}}|t|d�|t|d�}
}|
|jdk�s,||jdk�rCt|
|jd�t||jd�f|_t�|j�|||
|f}|d}	|	d@dk}|	d@�rj|	d@d}t�d|j�
d
|>��}|j�
d�d}|j��|_n	qZ|du�r�t�||_|jdk�r�d|_d|jv�r�d |_|j�|jdd�|j�d tj�|_|jd=nd|_|j�dtj�|_|j�r�|j� |j|j�|�p�|j!��fd!d"�}||_z�|jdk�r�d|_nx|jdk�r&|j\}}}
}|
|||f}t�|�|j�"d|�}|du�rd }||�d#}nd}||j�"d$d��}tj#�$|||�|_n4|j�r4|�%|j|j�|_n&|du�rZ|j\}}}
}|
|||f}t�|�tj#�$d |||�d#�|_Wn
t&�yeYnw|du�r�|dk�rz|du�rz||jd<d%|||
|f|j||ffg|_nt�d&D]}||v�r�|||j|<�q�||jv�r�|j|=�q�|dk�rЈ�r�d'nd(|_|jd'k�r�|�s�dd)l'm'}||j!�}||_(dS�|_)||_*dS)*Nr)rrrr���rzcannot seek to frame T�;�!�r r�duration�r!��comment��	extensionr�NETSCAPE2.0�loop�,�	�rr�@rrr"�transparency�RGBAcs4�rt�j|d|dd��}|S|||f}|S)Nr )�tupler,)�color��
frame_paletterr�_rgbs

�z GifImageFile._seek.<locals>._rgb)rr�gif)rIrLrNrP�P�L)�copy)+�_GifImageFile__offset�dispose�dispose_extentr?r-r8r/�disposal_methodr'�load�
ValueErrorrrrr%r.r)�size�maxr&r�_decompression_bomb_checkrr*r9�pyaccessr$�moder@�putpalettealpha�convert�FLOYDSTEINBERG�paster+�get�core�fill�_crop�AttributeErrorr_r,�_frame_palette�_frame_transparency)rrAr,r$�frame_transparency�	interlace�frame_dispose_extentr�blockr3�dispose_bits�x0�y0�x1�y1r4r[�dispose_sizerX�dispose_mode�kr_rrYrr2�s"
�����
 "
�
S




���


��

�



zGifImageFile._seekcs�|jdkrd|jvrtj�|j|j|jd�|_n*|j|_|j	r=d|_tj�d|j|j
p-d�|_|jj|j	���d|_	nd|_d|_t
���dS)NrrUr]r^)r?r$rrprqrjrfr@�_prev_imrtru�
putpalette�getdata�super�load_prepare�r��	__class__rrr�ds

��zGifImageFile.load_preparecCs�|jdkrdS|jdur|j�|jd�|j�d�}n|j�d�}|�||j�}|j|_|jj|_|jdkrA|j�	||j|�dS|j�	||j�dS)NrrVr")
r?rur@rkrlrrrbr�rjrn)r�frame_imrrr�load_endws



zGifImageFile.load_endcCs|jS�N)r?r�rrrr.�szGifImageFile.tellcCsPz#z
|j|jkr
|j��Wn	tyYnwWd|_dSWd|_dSd|_wr�)r-r�closersr�rrr�
_close__fp�s
���
�zGifImageFile._close__fp)�__name__�
__module__�__qualname__�format�format_description�!_close_exclusive_fp_after_loadingr+rr7�propertyr<r=r8r2r�r�r.r��
__classcell__rrr�rr2s$

[rr^r])�1r^r]FcCs�|jtvr|��|St�|j�dkrV|rQd}|jr%t|j��d�d}|jdtj	|d�}|jjdkrO|jj
��D]}|ddkrN|jj
||jd	<|Sq:|S|�d�S|�d
�S)a
    Takes an image (or frame), returns an image in a mode that is appropriate
    for saving in a Gif.

    It may return the original image, or it may return an image converted to
    palette or 'L' mode.

    UNDONE: What is the point of mucking with the initial call palette, for
    an image that shouldn't have a palette, or it would be a mode 'P' and
    get returned in the RAWMODE clause.

    :param im: Image object
    :param initial_call: Default false, set to true for a single frame.
    :returns: Image object
    r"�rr r])r,�colorsrVrrUr^)
rj�RAWMODErdr�getmodebaser,r)r�rl�ADAPTIVEr��keysr$)r@�initial_call�palette_size�rgbarrr�_normalize_mode�s&
�

r�c		Csfd}|rt|tttf�rt|dd��}t|tj�rt|j�}|jdkr1|s0|j�d�dd�}n|s>tdd�t	d�D��}tjd|d�|_|r�g}t	dt
|�d	�D]%}t|||d	��}z|jj|}Wnt
yqd}Ynw|�|�qRt|�D]\}}|dur�t	t
|��D]}||vr�|||<nq�q||�|�}nt||�}|dur�|�||�S||j_|S)
at
    Normalizes the palette for image.
      - Sets the palette to the incoming palette, if provided.
      - Ensures that there's a palette for L mode images
      - Optimizes the palette if necessary/desired.

    :param im: Image object
    :param palette: bytes object containing the source palette, or ....
    :param info: encoderinfo
    :returns: Image object
    Nir]r"css�|]}|dVqdS)r Nr)�.0r6rrr�	<genexpr>�s�z%_normalize_palette.<locals>.<genexpr>�r,rr )�
isinstance�bytes�	bytearray�listrr,rjr@�
getpaletter(r)rWr��KeyError�append�	enumerate�
remap_palette�
_get_optimize)	r@r,r$�source_palette�used_palette_colorsr6�source_color�index�jrrr�_normalize_palette�sJ

����
r�c	Cs�t|d�}|j��D]\}}|j�||�q
t|||j�}t||j�D]}|�|�q#d}t|�r5|dB}t	||d|�dt|�f|_
t�||dd|j
dt|jfg�|�d�dS)NTrrT�rrrr\�)r�r$�items�encoderinfo�
setdefaultr��_get_global_header�write�
get_interlace�_write_local_header�
encoderconfigr�_saverfr�rj)r@rr,�im_outr��vrr3rrr�_write_single_frame�s
$r�c	Cs�|j�d|j�d��}|j�d|j�d��}g}d}d}t�|g|j�dg��D]�}t�|�D]�}	t|	���}	|dkrL|	j�	�D]\}
}|j�
|
|�q@t|	||j�}	|j��}t|t
tf�re|||d<t|t
tf�rr|||d<|d7}|r�|d}
|�d�dkr�|dur�|j�d|j�dd	��}t|	|�}t�d
|	j|�}|�|ddj�|}n|
d}t|	�t|�kr�t�|	|�}nt�|	�d�|�d��}|��}|s�|r�|
d
d|d7<q/nd}|�|	||d��q/q(t|�dk�r:|D]?}|d}	|d�st|	|d
�D]}|�|��q
d}n|�sd|d
d<|	�|d�}	|ddd�}t||	||d
�q�dSd|jv�rWt|jdt
tf��rYt |jd�|jd<dSdSdS)NrI�disposalr�
append_imagesrrEr!rU)rrrr]r@r"r�)r@�bboxr�r�r�T�include_color_table)!r�ror$�	itertools�chainr�Iteratorr�r_r�r�r�r�r�rW�_get_backgroundr�newrfr�r,�_get_palette_bytesr�subtract_modulorl�getbboxr�r)r�r��crop�_write_frame_data�sum)r@rr,rIr��	im_frames�frame_count�
background_im�
imSequence�im_framer�r�r��previousrXr�base_im�deltar��
frame_datar�offsetrrr�_write_multiple_frames
s|
�
���-
��r�cCst|||dd�dS)NT)�save_all)r�)r@r�filenamerrr�	_save_allXsr�cCs�d|jvs
d|jvr|j�d|j�d��}nd}|j�dd�|jd<|r*t|||�s0t|||�|�d�t|d�r@|��dSdS)Nr,�optimizeTrF�flush)r�r$ror�r�r��hasattrr�)r@rr�r�r,rrrr�\s

�r�cCs$|j�dd�}t|j�dkrd}|S)Nrwr�r)r�ro�minrf)r@rwrrrr�msr�cCs�d}z|jd}Wn	tyYn$wt|�}d}t||j�}|dur6z|�|�}Wnty5d}Ynwd|jvrEt|jdd�}nd}t|j�dd��}|sX|dksX|r�|r\dnd}	|	|d	>O}	|shd}|�d
td�td�t|	�t	|�t|�td��d
|jvr�dt
|jd
�kr�|�d
td��|jd
}
t|
t�r�|
�
�}
tdt
|
�d�D]}|
||d�}|�tt
|��|�q�|�td��d|jvr�|jd}
|�d
td�td�dtd�td�t	|
�td��|j�d�}|�rt|�}t|�}|�r|dB}||B}|�dt	|d�t	|d�t	|jd�t	|jd�t|��|�rD|�rD|�t|��|�td��dS)NFrUTrIrrr�rr!rGrHrSrLrKrMrPrrOr r�rrQr)r�r��intr�r�reror�r	�o16r)r��str�encoder(r��_get_color_table_sizerf�_get_header_palette)rr@r�r3�transparent_color_existsrUr�rIr��packed_flagrLr6�subblock�number_of_loopsr��
palette_bytes�color_table_sizerrrr�ws���
�������




��������

�
�����r�c
Cs|��}ztt|d��S}|jdkrtjd|g|tjd�n:dd|g}dg}tj|tjtjd�}tj||j|tjd�}|j�	�|�
�}	|	rJt�|	|��|�
�}	|	rVt�|	|��Wd�n1s`wYWzt�
|�WdStyxYdSwzt�
|�Wwty�Yww)N�wbr"�ppmtogif)�stdout�stderr�ppmquant�256)�stdinr�r�)�_dump�openrj�
subprocess�
check_call�DEVNULL�Popen�PIPEr�r��wait�CalledProcessError�os�unlink�OSError)
r@rr��tempfilerC�	quant_cmd�	togif_cmd�
quant_proc�
togif_proc�retcoderrr�_save_netpbm�sL
�

��
������r
cCs�|jdvrD|rF|�dd�rHtp|jdk}|s|j|jdkrJg}t|���D]\}}|r1|�|�q&|sBt|�dkrLt	|�t|�krN|SdSdSdSdSdSdS)aL
    Palette optimization is a potentially expensive operation.

    This function determines if the palette should be optimized using
    some heuristics, then returns the list of palette entries in use.

    :param im: Image object
    :param info: encoderinfo
    :returns: list of indexes of palette entries in use, or None
    )r]r^r�rr^irN)
rjro�_FORCE_OPTIMIZE�width�heightr��	histogramr�r)rg)r@r$�optimiser�r6�countrrrr�s 
��r�cCs6|sdSt|�dkrdSt�t�t|�dd��dS)NrrRrr r!)r)�math�ceil�log)r�rrrr�%s
r�cCs<t|�}d|>t|�d}|dkr|td�d|7}|S)z�
    Returns the palette, null padded to the next power of 2 (*3) bytes
    suitable for direct inclusion in the GIF header

    :param palette_bytes: Unpadded palette bytes, in RGBRGB form
    :returns: Null padded palette
    r!r r)r�r)r	)r�r��actual_target_size_diffrrrr�/s
r�cCs|jjS)z�
    Gets the palette for inclusion in the gif header

    :param im: Image object
    :returns: Bytes, len<=768 suitable for inclusion in gif header
    r�)r@rrrr�Asr�c
Csdd}|r0|}t|t�r0z
|j�||�}W|Sty/}zt|�dkr*WYd}~dS�d}~ww|S)Nrz$cannot allocate more than 256 colors)r�rWr,�getcolorrer�)r@�infoBackgroundrrDrrrr�Ks
���r�cCs�d}dD]*}|r.||vr.|dkr||dks)|dkr*dt||�kr(dks*nqd}nq|j�d	�dkr9d}t||�d
��}t|�}t|�}d|t|jd�t|jd�t|d�t|�td�t	|�gS)
z2Return a list of strings representing a GIF headers87a)rUrIrPrLrIrrLrrMs89arrsGIFr)
r)r$ror�r�r�r�rfr	r�)r@r$r�extensionKeyrr�r�rrrr�_s2&����
�r�c	CsTz&||_t|||d�t�||dd|jdt|jfg�|�d�W|`dS|`w)Nrr\r�r�)r�r�rr�rfr�rjr�)rr�r��paramsrrrr��s�r�cCsdt||�}|duri}d|vrd|jvr|jd|d<t|||�}|j|_|j|_t||�}||fS)a
    Legacy Method to get Gif data from image.

    Warning:: May modify image data.

    :param im: Image object
    :param palette: bytes object containing the source palette, or ....
    :param info: encoderinfo
    :returns: tuple of(list of header items, optimized palette)

    Nr)r�r$r�r,r@r�)r@r,r$r��im_mod�headerrrr�	getheader�s

rr�cKs0Gdd�d�}|��|�}t||||�|jS)a�
    Legacy Method

    Return a list of strings representing this image.
    The first string is a local image header, the rest contains
    encoded image data.

    :param im: Image object
    :param offset: Tuple of (x, y) pixels. Defaults to (0,0)
    :param \**params: E.g. duration or other encoder info parameters
    :returns: List of Bytes containing gif encoded frame data

    c@seZdZgZdd�ZdS)zgetdata.<locals>.CollectorcSs|j�|�dSr�)rr�)rrrrrr��rz getdata.<locals>.Collector.writeN)r�r�r�rr�rrrr�	Collector�sr)rdr�r)r@r�rrrrrrr��s
r�z.gifz	image/gif)F)NN)r�),r�rrr��rrrrr�_binaryrr%r	r
r�rrr�r�r�r�r�r�r�r�r�r
rr�r�r�r�r�r�r�rr��
register_openr��
register_save�register_save_all�register_extension�
register_mimerrrr�<module>sJ	i
$5N

T2%

'

!

Youez - 2016 - github.com/yon3zu
LinuXploit