403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/PIL/__pycache__/GifImagePlugin.cpython-39.pyc
a

h�azv�@snddlZddlZddlZddlZddlmZmZmZmZm	Z	ddl
mZddl
m
Z
ddl
mZdd�ZGd	d
�d
ej�Zdddd
�Zd6dd�Zdd�Zdd�Zdd�Zdd�Zd7dd�Zdd�Zdd�Zdd �ZdZd!d"�Zd#d$�Zd%d&�Zd'd(�Z d)d*�Z!d+d,�Z"d-d.�Z#d8d/d0�Z$d9d2d3�Z%e�&ej'ee�e�(ej'e�e�)ej'e�e�*ej'd4�e�+ej'd5�dS):�N�)�Image�
ImageChops�	ImageFile�ImagePalette�
ImageSequence)�i16le)�o8)�o16lecCs|dd�dvS)N�)sGIF87asGIF89a�)�prefixrr�6/usr/lib/python3.9/site-packages/PIL/GifImagePlugin.py�_accept)srcsteZdZdZdZdZdZdd�Zdd�Ze	d	d
��Z
e	dd��Zd
d�Zdd�Z
�fdd�Zdd�Zdd�Z�ZS)�GifImageFileZGIFzCompuserve 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	@r�|d
|jd<|j�d|>�}td
t	|�d�D]X}|d||kr�||dkr�||dks�nt
�d|�}||_|_
q�q�|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._opencCs\|jdurV|��}z|�|��d�qWn tyJ|��d|_Yn0|�|�|jS)Nr)r.r,�seek�EOFError�r�currentrrr�n_frames^s

zGifImageFile.n_framescCsh|jdurb|jdur"|jdk|_n@|��}z|�d�d|_WntyVd|_Yn0|�|�|jS)NrTF)r/r.r,r6r7r8rrr�is_animatedjs




zGifImageFile.is_animatedcCs�|�|�sdS||jkr0|dkr&d|_|�d�|j}t|jd|d�D]L}z|�|�WqJty�}z |�|�td�|�WYd}~qJd}~00qJdS)Nrrzno more images in GIF file)Z_seek_check�_GifImageFile__frame�imr0r&r7r6)r�frameZ
last_frame�f�errrr6{s



zGifImageFile.seekcCs�|dkr:d|_d|_gd�|_d|_|j�|j�d|_n|jrH|�	�||jdkrdt
d|����||_g|_|j|_|jr�|j�|j�|��r�q�d|_|jr�|j
�|j|j�ddlm}||j�|_i}d}d}|j�d�}|r�|dkr��q&q�|dk�r&|j�d�}|��}|dd	k�rl|d}|d@�r<|d
}t|d�d|d<d
|@}	|	d?}	|	�r|	|_n�|ddk�r�|r�d|v�r�|d|7<n||d<|��}�qzq�nd|ddk�r||j��f|d<|dd�dk�r|��}t|�d
k�r|ddk�rt|d�|d<|���r$�qq�|dkr�|j�d�}t|d�t|d�}
}|
t|d�|t|d�}}
||jdk�s�|
|jdk�r�t||jd�t|
|jd�f|_|
|||
f|_|d}|d@dk}|d@�r|d@d}t�d|j�d
|>��|_|j�d�d}|j��|_�q&q�q�z�|jdk�r<d|_n�|jdk�r�|j\}
}}}
||
|
|f}t�|�|j�d|�}|du�r�|j�d d�}tj� d!||�|_n`|j
�r�|�!|j
|j�|_nD|du�r
|j\}
}}}
||
|
|f}t�|�tj� d!||�|_Wnt"�y Yn0|du�rvd}|du�rT|dk�rP||jd<n|}d"|
|||
f|j|||ffg|_nt#�d#D]4}||v�r�|||j|<n||jv�r~|j|=�q~d$|_$|j�r�d!|_$dS)%Nr)rrrr���rzcannot seek to frame )�copy�;�!�rr�duration�r��comment��	extensionr�NETSCAPE2.0�loop�,�	�rr�@rrr �transparencyr�P�gif)rFrIrKrM�L)%Z_GifImageFile__offsetZdisposeZdispose_extentr<r+r6r-Zdisposal_methodr%�load�
ValueErrorrrr=ZpasterBr)r*rr#r,r'�size�maxr$rr(rZ_decompression_bomb_checkr"�get�core�fillZ_crop�AttributeErrorr7�mode)rr>rBr"Zframe_transparency�	interlacer�blockr1Zdispose_bitsZx0Zy0Zx1Zy1r2Zdispose_size�colorrR�krrrr0�s�




 "




�




��

zGifImageFile._seekcs>|js,d|jvr,tj�|j|j|jd�|_tt|��	�dS)NrR)
r=r"rr[r\r^rX�superr�load_prepare�r��	__class__rrrdCszGifImageFile.load_preparecCs|jS�N)r<rerrrr,IszGifImageFile.tellcCsFz8z|j|jkr|j��Wnty.Yn0Wd|_nd|_0dSrh)r+r�closer]rerrr�
_close__fpLszGifImageFile._close__fp)�__name__�
__module__�__qualname__�formatZformat_descriptionZ!_close_exclusive_fp_after_loadingr)rr5�propertyr:r;r6r0rdr,rj�
__classcell__rrrfrr2s 

9rrUrS)�1rUrSFcCsp|jtvr|��|St�|j�dkrf|r\d}|jrJt|j��d�d}|jdtj	|d�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 �rrrS)r*�colorsrU)
r^�RAWMODErVrZgetmodebaser*r'�getdata�convertZADAPTIVE)r=Zinitial_callZpalette_sizerrr�_normalize_mode]s

rwc		Csnd}|r>t|tttf�r(t|dd��}t|tj�r>t|j�}|jdkrb|s�|j�d�dd�}n*|s|tdd�t	d�D��}tjd|d�|_|�rBg}t	dt
|�d	�D]J}t|||d	��}z|jj|}Wnt
y�d}Yn0|�|�q�t|�D]:\}}|dur�t	t
|��D]}||v�r|||<q��qq�|�|�}n t||�}|du�rb|�||�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
    NirSr css|]}|dVqdS)rNr)�.0r4rrr�	<genexpr>��z%_normalize_palette.<locals>.<genexpr>�r*rr)�
isinstance�bytes�	bytearray�listrr*r^r=Z
getpaletter&r'�tuplers�KeyError�append�	enumerateZ
remap_palette�
_get_optimize)	r=r*r"Zsource_palette�used_palette_colorsr4Zsource_color�index�jrrr�_normalize_palette{sB






r�c	Cs�t|d�}|j��D]\}}|j�||�qt|||j�}t||j�D]}|�|�qFd}t|�rj|dB}t	||d|�dt|�f|_
t�||dd|j
dt|jfg�|�d�dS)NTrrQ�rrrrT�)rwr"�items�encoderinfo�
setdefaultr��_get_global_header�write�
get_interlace�_write_local_headerZ
encoderconfigr�_saverXrtr^)r=rr*Zim_outrb�vrr1r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|	���}	|dkr�|	j�	�D]\}
}|j�
|
|�q�t|	||j�}	|j��}t|t
tf�r�|||d<t|t
tf�r�|||d<|d7}|�r�|d}
|�d�dk�rd|du�r^|j�d|j�dd	��}t|	|�}t�d
|	j|�}|�|ddj�|}n|
d}t|	�t|�k�r�t�|	|�}nt�|	�d�|�d��}|��}|�s�|r`|
d
d|d7<q`nd}|�|	||d��q`qPt|�dk�r�|D]�}|d}	|d�s:t|	|d
�D]}|�|��q"d}n0|�sLd|d
d<|	�|d�}	|ddd�}t||	||d
��q�dSd|jv�r�t|jdt
tf��r�t |jd�|jd<dS)NrF�disposalrZ
append_imagesrrArrR)rrrrSr=r r�)r=�bboxr�r�r�T�include_color_table)!r�rZr"�	itertools�chainr�IteratorrwrBr�r�r�r|rr��_get_backgroundr�newrXZ
putpaletter*�_get_palette_bytesrZsubtract_modulorvZgetbboxr�r'r�r�Zcrop�_write_frame_data�sum)r=rr*rFr�Z	im_framesZframe_countZ
background_imZ
imSequence�im_framerbr�r�ZpreviousrarZbase_imZdeltar�Z
frame_datar�offsetrrr�_write_multiple_frames�sv

�
�
�r�cCst|||dd�dS)NT)�save_all)r�)r=r�filenamerrr�	_save_allsr�cCs�d|jvsd|jvr,|j�d|j�d��}nd}|j�dd�|jd<|rTt|||�s`t|||�|�d�t|d�r||��dS)Nr*�optimizeTrC�flush)r�r"rZr�r�r��hasattrr�)r=rr�r�r*rrrr�s

r�cCs$|j�dd�}t|j�dkr d}|S)Nr_r�r)r�rZ�minrX)r=r_rrrr�(sr�cCs�d}z|jd}Wnty$YnH0t|�}d}t||j�}|durlz|�|�}Wntyjd}Yn0d|jvr�t|jdd�}nd}t|j�dd��}|s�|dks�|�r|r�dnd}	|	|d	>O}	|s�d}|�d
td�td�t|	�t	|�t|�td��d
|jv�r�dt
|jd
�k�r�|�d
td��|jd
}
t|
t��r\|
�
�}
tdt
|
�d�D],}|
||d�}|�tt
|��|��ql|�td��d|jv�r�|jd}
|�d
td�td�dtd�td�t	|
�td��|j�d�}|�r4t|�}t|�}|�r4|dB}||B}|�dt	|d�t	|d�t	|jd�t	|jd�t|��|�r�|�r�|�t|��|�td��dS)NFrRTrFrrr�rrrDrErPrIrHrJrMrrLrr�rrNr)r�r��intr�r�rWrZr�r	�o16r'r|�str�encoder&r��_get_color_table_sizerX�_get_header_palette)rr=r�r1Ztransparent_color_existsrRr�rFr�Zpacked_flagrIr4ZsubblockZnumber_of_loopsr��
palette_bytes�color_table_sizerrrr�2s�

�������
 

��������

�
�����r�c
Cs|��}z�t|d���}|jdkr8tjd|g|tjd�ntdd|g}dg}tj|tjtjd�}tj||j|tjd�}|j�	�|�
�}	|	r�t�|	|��|�
�}	|	r�t�|	|��Wd�n1s�0YWzt�
|�Wnty�Yn0n&zt�
|�Wnt�yYn00dS)N�wbr Zppmtogif)�stdout�stderrZppmquantZ256)�stdinr�r�)Z_dump�openr^�
subprocessZ
check_callZDEVNULL�Popen�PIPEr�ri�waitZCalledProcessError�os�unlink�OSError)
r=rr�Ztempfiler?Z	quant_cmdZ	togif_cmdZ
quant_procZ
togif_procZretcoderrr�_save_netpbm�sB
�

��
,�r�cCs�|jdvr�|r�|�dd�r�tp&|jdk}|s<|j|jdkr�g}t|���D]\}}|rL|�|�qL|s�t|�dkr�t	|�t|�kr�|SdS)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
    )rSrUr�rrUirN)
r^rZ�_FORCE_OPTIMIZE�widthZheightr�Z	histogramr�r'rY)r=r"Zoptimiser�r4�countrrrr��s
��r�cCs:|sdSt|�dkrdSt�t�t|�dd��dSdS)NrrOrrr)r'�mathZceil�log)r�rrrr��s
r�cCs<t|�}d|>t|�d}|dkr8|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
    rrr)r�r'r	)r�r�Zactual_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��sr�c
Csnd}|rj|}t|t�rjz|j�||�}Wn@tyh}z(t|�dkrRWYd}~dS�WYd}~n
d}~00|S)Nrz$cannot allocate more than 256 colors)r|r�r*ZgetcolorrWr�)r=ZinfoBackgroundrr@rrrr�s
r�cCs�d}dD]T}|r||vr|dkr,||dks|dkrTdt||�krPdksTqqd}qrq|j�d	�dkrrd}t||�d
��}t|�}t|�}d|t|jd�t|jd�t|d�t|�td�t	|�gS)
z2Return a list of strings representing a GIF headers87a)rRrFrMrIrFrrIrrJs89arrsGIFr)
r'r"rZr�r�r�r�rXr	r�)r=r"rZextensionKeyrr�r�rrrr�s:������
�r�c	CsVzJ||_t|||d�t�||dd|jdt|jfg�|�d�W|`n|`0dS)NrrTr�r�)r�r�rr�rXrtr^r�)rr�r��paramsrrrr�As�r�cCsdt||�}|duri}d|vr6d|jvr6|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�Zim_mod�headerrrr�	getheaderUs

r�r�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�|�dSrh)rr�)rrrrrr��sz getdata.<locals>.Collector.writeN)rkrlrmrr�rrrr�	Collector�sr�)rVr�r)r=r�r�r�rrrrruss
ruz.gifz	image/gif)F)F)NN)r�),r�r�r�r��rrrrrZ_binaryrr#r	r
r�rrrtrwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ruZ
register_openrnZ
register_saveZregister_save_allZregister_extensionZ
register_mimerrrr�<module>sH	*
5N

T2%

'

!

Youez - 2016 - github.com/yon3zu
LinuXploit