Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 iazvã@snddlZddlZddlZddlZddlmZmZmZmZm Z ddl m Z ddl m Z ddl mZdd„ZGd d „d ejƒZd d d d œZd5dd„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$d9d1d2„Z%ej&ej'eeƒej(ej'eƒej)ej'eƒej*ej'd3ƒej+ej'd4ƒdS):éNé)ÚImageÚ ImageChopsÚ ImageFileÚ ImagePaletteÚ ImageSequence)Úi16le)Úo8)Úo16lecCs|dd…dkS)NéóGIF87aóGIF89a)r r ©)Úprefixrrú3/tmp/tmp5hum_rxs/lib64/python/PIL/GifImagePlugin.pyÚ_accept)srcsteZdZdZdZdZdZdd„Zdd„Ze d d „ƒZ e d d „ƒZ d d„Z dd„Z ‡fdd„Zdd„Zdd„Z‡ZS)Ú GifImageFileZGIFzCompuserve GIFFNcCs,|jjdƒ}|r(|dr(|jj|dƒSdS)Nrr)ÚfpÚread)ÚselfÚsrrrÚdata:s  zGifImageFile.datacCs |jjdƒ}t|ƒstdƒ‚|dd…|jd<t|dƒt|dƒf|_g|_|d}|d@d}|d @rò|d |jd <|jjd |>ƒ}xltd t |ƒd ƒD]X}|d ||koÎ||dkoÎ||dkns–t j d|ƒ}||_ |_ Pq–W|j|_|jjƒ|_d|_d|_|jd ƒ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ÚirrrÚ_open@s*  :   zGifImageFile._openc Csb|jdkr\|jƒ}yx|j|jƒdƒqWWn"tk rP|jƒd|_YnX|j|ƒ|jS)Nr)r0r.ÚseekÚEOFError)rÚcurrentrrrÚn_frames^s  zGifImageFile.n_framesc Csj|jdkrd|jdk r"|jdk|_nB|jƒ}y|jdƒd|_Wntk rXd|_YnX|j|ƒ|jS)NrTF)r1r0r.r8r9)rr:rrrÚ is_animatedjs      zGifImageFile.is_animatedcCsž|j|ƒsdS||jkr0|dkr&d|_|jdƒ|j}xbt|jd|dƒD]J}y|j|ƒWqLtk r”}z|j|ƒtdƒ|‚WYdd}~XqLXqLWdS)Nrrzno more images in GIF file)Z _seek_checkÚ_GifImageFile__frameÚimr2r(r9r8)rÚframeZ last_frameÚfÚerrrr8{s    zGifImageFile.seekcCsê|dkr>d|_d|_ddddg|_d"|_|jj|jƒd|_n|jrL|j ƒ||jdkrht d|›�ƒ‚||_g|_|j|_ |jr¤|j j|jƒx |j ƒrœq’Wd|_|jr¼|j j|j|jƒddlm}||jƒ|_i}d}d}�xZ|j jdƒ}| pü|dk�rPqä|dk�r>|j jdƒ}|j ƒ}|ddk�rz|d}|d@�rJ|d}t|dƒd |d <d |@} | d ?} | �r*| |_n°|dd k�rÆx8|�rÀd|k�r¬|d|7<n||d<|j ƒ}�qŠWqänd|ddk�r*||j jƒf|d<|dd…dk�r*|j ƒ}t|ƒdk�r*|ddk�r*t|dƒ|d<x|j ƒ�r:�q,Wqä|dkrä|j jdƒ}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}tjd|j jd|>ƒƒ|_|j jdƒd}|j jƒ|_PqäqäWyæ|jd k�rTd|_nÎ|jd k�rÂ|j\} } } } | | | | f}tj|ƒ|jjd|ƒ}|dk�r®|jjddƒ}tjj d||ƒ|_n`|j �rÞ|j!|j |jƒ|_nD|dk �r"|j\} } } } | | | | f}tj|ƒtjj d||ƒ|_Wnt"k �r:YnX|dk �r�d#}|dk �rn|dk�rj||jd<n|}d | | | | f|j|||ffg|_nt#‚xZpasterBr+r,rr%r.r)ÚsizeÚmaxr&rr*rZ_decompression_bomb_checkr$ÚgetÚcoreÚfillZ_cropÚAttributeErrorr9Úmode)rr?rBr$Zframe_transparencyÚ interlacerÚblockr3Z dispose_bitsZx0Zy0Úx1Úy1r4Z dispose_sizeÚcolorrQÚkrrrr2‹sâ           "                  zGifImageFile._seekcs@|j r.d|jkr.tjj|j|j|jdƒ|_tt|ƒj ƒdS)NrQ) r>r$rr[r\r^rXÚsuperrÚ load_prepare)r)Ú __class__rrrfCszGifImageFile.load_preparecCs|jS)N)r=)rrrrr.IszGifImageFile.tellcCsBz4y|j|jkr|jjƒWntk r0YnXWdd|_XdS)N)r-rÚcloser])rrrrÚ _close__fpLs   zGifImageFile._close__fp)Ú__name__Ú __module__Ú __qualname__ÚformatZformat_descriptionZ!_close_exclusive_fp_after_loadingr+rr7Úpropertyr;r<r8r2rfr.riÚ __classcell__rr)rgrr2s 9 rrTrR)Ú1rTrRFcCsp|jtkr|jƒ|Stj|jƒdkrf|r\d}|jrJt|jjƒdƒd}|jdtj |d�S|jdƒS|jdƒ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 rR)r,ÚcolorsrT) r^ÚRAWMODErVrZ getmodebaser,r)ÚgetdataÚconvertZADAPTIVE)r>Z initial_callZ palette_sizerrrÚ_normalize_mode]s  rvc Cs~d}|r>t|tttfƒr(t|dd…ƒ}t|tjƒr>t|jƒ}|jdkrb|sŒ|jjdƒdd…}n*|s|tdd„t dƒDƒƒ}tjd|d�|_|�rRg}x`t dt |ƒd ƒD]L}t |||d …ƒ}y|jj |}Wnt k rèd}YnX|j|ƒq¨WxLt|ƒD]@\}}|dk�rx*t t |ƒƒD]}||k�r"|||<P�q"W�qW|j|ƒ}n t||ƒ}|dk �rr|j||ƒ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 NirRr"css|]}|dVqdS)r Nr)Ú.0r6rrrú ”sz%_normalize_palette..)r,rr )Ú isinstanceÚbytesÚ bytearrayÚlistrr,r^r>Z getpaletter(r)ÚtuplerrÚKeyErrorÚappendÚ enumerateZ remap_paletteÚ _get_optimize) r>r,r$Zsource_paletteÚused_palette_colorsr6Z source_colorÚindexÚjrrrÚ_normalize_palette{sB           r…cCsÀt|dƒ}x$|jjƒD]\}}|jj||ƒqWt|||jƒ}xt||jƒD]}|j|ƒqLWd}t|ƒrr|dB}t ||d|ƒdt|ƒf|_ t j ||dd|j dt|jfgƒ|jdƒdS) NTrrPrrSó)rr)rr)rvr$ÚitemsÚ encoderinfoÚ setdefaultr…Ú_get_global_headerÚwriteÚ get_interlaceÚ_write_local_headerZ encoderconfigrÚ_saverXrsr^)r>rr,Zim_outrdÚvrr3rrrÚ_write_single_frame°s $r�c CsÖ|jjd|jjdƒƒ}|jjd|jjdƒƒ}g}d}d}�xÀtj|g|jjdgƒƒD�]¢}�xštj|ƒD�]Š} t| jƒƒ} |dkr¨x$| jj ƒD]\} } |jj | | ƒqŽWt | ||jƒ} |jjƒ} t |t tfƒrÚ||| d<t |t tfƒrô||| d<|d7}|�rÞ|d} | jdƒdk�rp|dk�rj|jjd|jjddƒƒ}t| |ƒ}tjd| j|ƒ}|j|dd jƒ|}n| d }t| ƒt|ƒk�r˜tj| |ƒ}ntj| jd ƒ|jd ƒƒ}|jƒ}|�sâ|rh| d d| d7<qhnd}|j| || d œƒqhWqTWt|ƒdk�rœxŒ|D]„}|d } |d �sPx"t| |d ƒD]}|j|ƒ�q6Wd}n0|�sbd|d d<| j|d ƒ} |d dd…}t|| ||d ƒ�qWdSd|jk�rÒt |jdt tfƒ�rÒt |jdƒ|jd<dS)NrFÚdisposalrZ append_imagesrr!rQrRr>r"rˆ)r>Úbboxrˆr’TÚinclude_color_tablerU)rrr)rr)!rˆrZr$Ú itertoolsÚchainrÚIteratorrvrBr‡r‰r…ryr|r}Ú_get_backgroundrÚnewrXZ putpaletter,Ú_get_palette_bytesrZsubtract_moduloruZgetbboxrr)rŠr‹ZcropÚ_write_frame_dataÚsum)r>rr,rFr‘Z im_framesZ frame_countZ background_imZ imSequenceÚim_framerdr�rˆZpreviousrcrZbase_imÚdeltar’Z frame_datarÚoffsetrrrÚ_write_multiple_framesÅsp"         rŸcCst|||dd�dS)NT)Úsave_all)rŽ)r>rÚfilenamerrrÚ _save_allsr¢cCs„d|jksd|jkr,|jjd|jjdƒƒ}nd}|jjddƒ|jd<| sXt|||ƒ rdt|||ƒ|jdƒt|dƒr€|jƒdS)Nr,ÚoptimizeTrCÚflush)rˆr$rZrŸr�r‹Úhasattrr¤)r>rr¡r r,rrrrŽs   rŽcCs$|jjddƒ}t|jƒdkr d}|S)Nr_rér)rˆrZÚminrX)r>r_rrrrŒ(srŒcCs®d}y|jd}Wntk r&YnJXt|ƒ}d}t||jƒ}|dk rpy|j|ƒ}Wntk rnd}YnXd|jkrŽt|jddƒ}nd}t|jjddƒƒ}|s¶|dks¶|�r|r¾dnd} | |d >O} |sÖd}|jd td ƒtd ƒt| ƒt |ƒt|ƒtdƒƒd |jk�r°dt |jd ƒk�r°|jd tdƒƒ|jd } t | t ƒ�r`| j ƒ} x@tdt | ƒdƒD],} | | | d…} |jtt | ƒƒ| ƒ�qrW|jtdƒƒd|jk�r|jd} |jd tdƒtdƒdtdƒtdƒt | ƒtdƒƒ|jjdƒ}|�rržr3Ztransparent_color_existsrQr‚rFr‘Z packed_flagrIr6ZsubblockZnumber_of_loopsr“Ú palette_bytesÚcolor_table_sizerrrr�2sb     6     : B r�c Csä|jƒ}z°t|dƒ�œ}|jdkr8tjd|g|tjd�ntdd|g}dg}tj|tjtjd�}tj||j|tjd�}|jj ƒ|j ƒ} | r”tj | |ƒ‚|j ƒ} | r¬tj | |ƒ‚WdQRXWdyt j |ƒWntk rÜYnXXdS)NÚwbr"Zppmtogif)ÚstdoutÚstderrZppmquantZ256)Ústdinr±r²)Ú_dumpÚopenr^Ú subprocessÚ check_callÚDEVNULLÚPopenÚPIPEr±rhÚwaitÚCalledProcessErrorÚosÚunlinkÚOSError) r>rr¡Útempfiler@Z quant_cmdZ togif_cmdZ quant_procZ togif_procÚretcoderrrÚ _save_netpbm†s4      rÂcCs�|jdkrŒ|rŒ|jddƒrŒtp&|jdk}|s<|j|jd krŒg}x&t|jƒƒD]\}}|rN|j|ƒqNW|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 rRrTr£rirN)rRrTi) r^rZÚ_FORCE_OPTIMIZEÚwidthÚheightr€Z histogramrr)rY)r>r$Zoptimiser‚r6Úcountrrrr�»s   r�cCs:|sdSt|ƒdkrdStjtjt|ƒddƒƒdSdS)NrrNrr r!)r)ÚmathÚceilÚlog)r®rrrr¬à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 r!r r)r¬r)r )r®r¯Zactual_target_size_diffrrrr­ê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>rrrr™üsr™cCsbd}|r^|}t|tƒr^y|jj||ƒ}Wn4tk r\}zt|ƒdkrJdS‚WYdd}~XnX|S)Nrz$cannot allocate more than 256 colors)ryr}r,ZgetcolorrWrª)r>ZinfoBackgroundrrArrrr—s  r—cCsÜd}xrdD]V}|r ||kr |dkr.||dks |dkrZdt||ƒkoPdkn rZq d }Pq W|jjd ƒd krxd }t||jd ƒƒ}t|ƒ}t|ƒ}d |t|jdƒt|jdƒt|d ƒt|ƒtdƒt |ƒgS)z2Return a list of strings representing a GIF headers87arQrFrLrIrrrJs89arrsGIFr)rQrFrLrI) r)r$rZr—r™r¬r©rXr r­)r>r$rZ extensionKeyrr®r¯rrrrŠs"  *" rŠcCsRzF||_t|||dƒtj||dd|jdt|jfgƒ|jdƒWd|`XdS)NrrSr†)rr)rˆr�rrŽrXrsr^r‹)rrœržÚparamsrrrršAs ršcCsdt||ƒ}|dkri}d|kr6d|jkr6|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ÚheaderrrrÚ getheaderUs   rÌcKs0Gdd„dƒ}|jƒ|ƒ}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..CollectorcSs|jj|ƒdS)N)rr)rrrrrr‹…sz getdata..Collector.writeN)rjrkrlrr‹rrrrÚ Collector‚srÍ)rVršr)r>ržrÊrÍrrrrrtss rtz.gifz image/gif)F)F)NN©rr)rÎ),r”rÇr½r¶ÚrrrrrZ_binaryrr%r r r©rrrsrvr…r�rŸr¢rŽrŒr�rÂrÃr�r¬r­r™r—rŠršrÌrtZ register_openrmZ register_saveZregister_save_allZregister_extensionZ register_mimerrrrÚsH    *  5N  T2%  '  !