*ec @sxddlmZdZyddlZWnek r?eZnXdfdYZyedWnek rtnXyddlZ WnKek rZ eZ e e d dkoerej d e nnXyddlZWn#ek rddlZeZnXdd lmZdd lmZmZddlZddlZddlZddlZee krwd Zn d ZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZdZ)dZ*dZ+Z,dZ-Z.dZdZ)dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9e:e dre j;Z;e j<Z<e j=Z=e j>Z>e j?Z?ngZ@iZAiZBiZCiZDi dddffd6dddffd6dddffd6dddffd6dddffd6dddddffd6ddddddffd 6dddddd!ffd"6ddd#d$d%d&ffd'6ddd%d(d)ffd*6ZEejFd+krd,ZGnd-ZGi d.efd6d/efd6eGd0efd6eGd1efd6d/efd6d/dfd6d/dfd 6d/dfd"6d/dfd'6d/dfd*6ZHd2ZIeJeEjKZLddd d"d'd3d4d5fZMd6ZNd7ZOd8ZPd9ZQdaRd:ZSd;ZTfd<ZUfd=ZVd>ZWd?fd@YZXdAZYdBfdCYZZdDeZfdEYZ[dFfdGYZ\dHfdIYZ]dJZ^ddKZ_dLdMZ`dNZadLdOZbedPZci ddfddfd/f6ddQfddfdRf6dd3fddfdSf6dd5fddfdTf6ddUfddfdVf6ddWfddfdXf6ddYfddfdZf6dd[fddfd\f6dd]fddfd^f6dd_fddfd`f6ddfdddfd/f6d"d"fdddfd/f6ZdddfedddfeGd0fs|b1s|u1ti4tf4cCsX|jd|jdf}t|j\}}|dkrC||fS||f|fSdS(Nii(tsizet _MODE_CONVtmodetNone(Rtshapettyptextra((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt_conv_type_shapes   sI;16sI;16LsI;16BcCstj|jS(N(R tgetmodetbasemode(R6((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt getmodebasescCstj|jS(N(R R<tbasetype(R6((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt getmodetypescCstj|jS(N(R R<tbands(R6((s//usr/lib64/python2.7/site-packages/PIL/Image.pytgetmodebandnames scCsttj|jS(N(tlenR R<RA(R6((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt getmodebandsscCstdkrdSyddlm}Wntk r7nXyddlm}Wntk r_nXyddlm}Wntk rnXyddlm}Wntk rnXyddlm}Wntk rnXdadS( s"Load standard file format drivers.iNi(tBmpImagePlugin(tGifImagePlugin(tJpegImagePlugin(tPpmImagePlugin(tPngImagePlugin(t _initializedtPILRERRFRGRHRI(RERFRGRHRI((s//usr/lib64/python2.7/site-packages/PIL/Image.pytpreinits.      cCstdkrdSi}tj}y|tjjtg}Wntk rOnXxtt|D]}tjj |}||krq`nxtj |D]}|ddkrtjj |\}}yBtjj d|zt |ttgWdtjd=XWqTtk rPtrQtdddt|d tjd qQqTXqqWd|||dkrQ|jj|n|d|}|j|||S(NitPPMt.(ttempfiletmktempRRtsave_ppmtsave(RRetformatR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt_dumps  cCs=d|jj|jj|j|jd|jdt|fS(Ns(<%s.%s image mode=%s size=%dx%d at 0x%X>ii(t __class__RRR6R4R(R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt__repr__scCs\|dkrLi}t|\}}||d<||d<|j|d<|St|dS(Nt__array_interface__R8ttypestrRy(R;ttobytesRl(RtnameRR8R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs   trawc Gs t|dkr2t|dtr2|d}n|dkrV|dkrV|j}n|jt|j||}|j|jtd|j dd}g}x9t r|j |\}}}|j ||rPqqW|dkrt d|ndj|S( sReturn image as a bytes objectiiRiisencoder error %d in tobytesR((RCR RiR6RRutsetimageRtmaxR4tTruetencodetappendt RuntimeErrortjoin( RRsRoRftbufsizeRytltsR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR s"%      cOs&tjdtdd|j||S(Ns8tostring() is deprecated. Please call tobytes() instead.t stackleveli(twarningstwarntDeprecationWarningR(RRotkw((s//usr/lib64/python2.7/site-packages/PIL/Image.pyttostring*s timagecCs|j|jdkr(tdn|jd}djd||jdfjdd||jd fjdd |jd|d gS( sReturn image as an XBM bitmapRs not a bitmaptxbmRs#define %s_width %d itasciis#define %s_height %d isstatic char %s_bits[] = { s};(RR6RRRR4R(RRRy((s//usr/lib64/python2.7/site-packages/PIL/Image.pyttobitmap:s #cGst|dkr2t|dtr2|d}n|dkrV|dkrV|j}nt|j||}|j|j|j|}|ddkrtdn|ddkrtdndS(s&Load data to image from a bytes objectiiRsnot enough image datascannot decode image dataN(( RCR RiR6RqRRtdecodeR(RRyRnRoRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt frombytesLs%  cOs tjdt|j||S(s Deprecated alias to frombytes s<fromstring() is deprecated. Please call frombytes() instead.(RRRR(RRoR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt fromstringascCs|jr|jr|jjr|jj|jjd|j_d|j_d|j_d|jkrt |jdt r|jj |jddn|jj |jdd|j_qn|jr|jj |jSdS(sExplicitly load pixel data.iRt transparencyR&N(RRtdirtyt putpalettetgetdataR6R7trawmodeRR tinttputpalettealphatputpalettealphast pixel_accessR(R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRns    cCsdS(sVerify file contents.N((R((s//usr/lib64/python2.7/site-packages/PIL/Image.pytverifysic Cs|sM|jdkr@|j|jr7|jj}qJd}qM|jSn|j|r|d krxtdn|jj||}|j|S|dkr|tkr|jj |}|j|S|d krt }n|jdkr|dkrd|j krddl m}d|_ttgtd D]}|d ^q<} |jd| |_d |j_|jny|jj||}Wnbtk ry1|jjt|j}|j||}Wqtk rtdqXnX|j|S(sConvert to other pixel formatRRRsillegal conversionR&Ri(Riii(RsRGBN(R6RRRRRtconvert_matrixRtADAPTIVEtquantizeR7tFLOYDSTEINBERGRRKRtbytest bytearraytrangeRRtconvertR>tKeyError( RR6RytditherRtcolorsRRtit bytePalette((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRsD          * /    icCs|j|r|j|jdkr8tdn|jdkre|jdkretdn|jjdd|j}|j|S|jj|||}|j|S(NRsbad mode for palette imageRRs7only RGB or L mode images can be quantized to a palettei(RR6RRRt _makeselfRR(RRtmethodtkmeansRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs    cCs&|j|jj}|j|S(sCopy raster data(RRRR(RR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs cCs-|j|dkr |jSt||S(sCrop region from imageN(RR7Rt _ImageCrop(Rtbox((s//usr/lib64/python2.7/site-packages/PIL/Image.pytcrops   cCsdS(sConfigure image decoderN((RR6R4((s//usr/lib64/python2.7/site-packages/PIL/Image.pytdraft.scCs>|dkr|}n|j|j|jj||dS(Ni(R7RRRtexpand(Rtxmargintymargin((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt_expand3s   cCs|jt|tjr(|}nt|dsFtdn|jjdkrq|j|j |jSg}xEt |jjD]1}|j |j|j |jj |qWt |j|S(s!Apply environment filter to imageRTs>filter argument should be ImageFilter.Filter instance or classi(RR t collectionstCallableRRRRARRTRRtgetbandtmergeR6(RRTtimsR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRTAs  /cCstj|jjS(sGet band names(R R<R6RA(R((s//usr/lib64/python2.7/site-packages/PIL/Image.pytgetbandsYscCs|j|jjS(s:Get bounding box of actual data (non-zero pixels) in image(RRtgetbbox(R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRfs cCs|j|jdkr|jj}g}x8tdD]*}||r;|j|||fq;q;Wt||krdS|S|jj|S(s(Get colors from image, up to given limitRRRi(RRRN( RR6Rt histogramRRRCR7t getcolors(Rt maxcolorsthtoutR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRts  cCs-|j|dk r&|jj|S|jS(s"Get image data as sequence object.N(RR7RR(Rtband((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs  cCsu|j|jjdkrhg}x9t|jjD]%}|j|jj|jq5Wt|S|jjS(sGet min/max valuei(RRRARRRt getextremaRi(RtextremaR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs # cCs|j|jjS(s,Get capsule pointer to internal image memory(RRtptr(R((s//usr/lib64/python2.7/site-packages/PIL/Image.pytgetims cCsl|jyIttkr?g|jjD]}t|^q)St|jjSWntk rgdSXdS(sGet palette contents.N( RRRRt getpaletteR tlistRR7(RR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs  & cCs|j|jj|S(sGet pixel value(RRtgetpixel(Rtxy((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs cCs[|j|jj\}}g|D]}t|^q&g|D]}t|^qBfS(sGet projection to x and y axes(RRt getprojectionR (RtxtyR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs cCsw|j|r0|j|jjd|jS|jdkrj|dkrZ|j}n|jj|S|jjS(sTake histogram of imageiRR(ii(RRN(RRRR6R7R(RtmaskR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs   cCsBtrtjdtddnddlm}|j|||S(sA(deprecated) Offset image in horizontal and/or vertical directions7'offset' is deprecated; use 'ImageChops.offset' insteadRii(t ImageChops(RRRRKRtoffset(RtxoffsettyoffsetR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs cCst|r'|d kr'|}d }n|d krCd |j}nt|dkrt|rm|j}n$t|r|j}n td||d|d|d|df}nt|rddlm}|j||j }njt|rZ|j |j |j krN|j dks6|j d krN|j |j }qNn|j }n|j |j rz|jn|r|j |j j|||j n|j j||d S( sPaste other image into regioniis,cannot determine region size; use 4-item boxii(t ImageColorRR&tRGBaN(ii(sRGBAR(RR7R4RCRRRKRtgetcolorR6RRRRRtpaste(RRRRR4R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyREs:       +        cCs|jt|tr&|j|St|tjs|jdkrut|\}}|j|j j ||Sgt dD]}||^q|j j }n|jdkrt dn|j|j j||S(sMap image through lookup tableRsI;16Ris+point operation not supported for this mode(RsI;16R(RR tImagePointHandlertpointRtSequenceR6RRRtpoint_transformRRAR(RtlutR6tscaleRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs  2cCs|j|jr |jn|jd kryt|jd}y|jj|WnJttfk r|jj |}|jd krtn||_nX|jj|_Wqt tfk rtdqXn|jdkrd}nd}t |rU|jd kr'tdn|j|jdkr|j d}qnJy|jj ||Wn,ttfk rt d|j|}nXd S|jj|j|d S( sSet alpha layertLAR&R%sillegal image modeiiRRN(RsRGBA(RsRGBA(RR(RRRR6R>RtsetmodeRlRRRRtfillbandRR4tputband(RtalphaR6RR((s//usr/lib64/python2.7/site-packages/PIL/Image.pytputalphas>        g?gcCs:|j|jr |jn|jj|||dS(s.Put data from a sequence object into an image.N(RRRRtputdata(RRyRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR s   RcCsddlm}|jd kr.tdn|jt||jre|j|j|j}nXt|t st t krdj d|D}qt |}n|j||}d|_||_d|j_|jd S( sPut palette data into an image.i(RRRsillegal image modeRcss|]}t|VqdS(N(tchr(t.0R((s//usr/lib64/python2.7/site-packages/PIL/Image.pys sRN(RR( RKRR6RRR RRRRRR(RRyRRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs     cCs3|j|jr |jn|jj||S(sSet pixel value(RRRRtputpixel(RRRw((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs   cCs|ttttfkr'tdn|j|jdkrIt}n|tkry|jj||}Wqt k rtdqXn|jj ||}|j |S(s Resize imagesunknown resampling filterRRsunsupported resampling filter(RR( tNEARESTtBILINEARtBICUBICt ANTIALIASRRR6RtstretchRltresizeR(RR4tresampleR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR*s    c Cs|rddl}| |jd}|j||j|d|j| |j|dg}|d}|j\}}g} g} xad|df||fd|ffD];\} } || | \} } | j| | j| qWt|jt| |j t | }t|jt| |j t | }||d|d\} } |jdd| |d<|jd d| |d <|j ||ft ||S|t ttfkrtd n|j|jdkrt }n|j|jj||S(s8Rotate image. Angle given as degrees counter-clockwise.iNigc SsB|\}}}}}}||||||||||fS(N(( RRtmatrixRRRRRfR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt transform]sig@iiisunknown resampling filterRR(ii(RR(tmathtpitcostsinR4RRtceilRtfloortminRtAFFINERRRRRR6RRtrotate( RtangleRRRRRtwRtxxtyyRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR"Ss2 " 1 ..  cKst|r|}n0t|dr?t|jr?|j}nd}|j||_d|_ttjj |dj }|syt |}Wqt k rt yt |}Wqt k rt |qXqXnyt|j}Wn(t k r"t t|j}nXt|rJtj|d}d}nd}z||||Wd|rz|jnXdS(sSave image to file or streamRRitwbiN((RRRRt encoderinfot encoderconfigRLRRRWtlowert EXTENSIONRRgR`tuppertbuiltinstopentclose(RtfpRtparamstfilenametextt save_handlerR/((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs@           cCs|dkrtndS(s$Seek to given frame in sequence fileiN(tEOFError(Rtframe((s//usr/lib64/python2.7/site-packages/PIL/Image.pytseeks cCst|d|d|dS(s'Display image (for debug purposes only)ttitletcommandN(t_show(RR8R9((s//usr/lib64/python2.7/site-packages/PIL/Image.pytshowscCs}|j|jjdkr.|jg}nEg}x<t|jjD](}|j|j|jj|qGWt|S(sSplit image into bandsi( RRRARRRRRRi(RRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pytsplits &cCsdS(sReturn current frame numberi((R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyttellscCsL|j\}}||dkrStt||d|d}t|d}n||dkrtt||d|d}t|d}n||f}||jkrdS|jd||jy|j||}Wn5tk r|tkrn|j|t }nX|j |_ |j |_ ||_d|_ dS(s9Create thumbnail representation (modifies image in place)iiN( R4RRRR7RRRRRRR6R(RR4RRRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt thumbnail,s,!!       ic Cst|tr+|j||d|d|St|drO|j\}}n|dkrjtdnt|j|d}|t krxS|D](\}}|j ||t |||qWn |j d|||||||S(sTransform imageRtfillRsmissing method dataiN(ii( R tImageTransformHandlerRRRR7RRR6tMESHt_Image__transformertQUAD( RR4RRyRR?RRtquad((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRes  # c Cs|d|d}|d|d}|tkrc|d|d|d|d|d|df}n|tkr|\} } } } t| | |} t| | |}t}| | d| d| |dd|f}nJ|tkr'|d|d|d|d|d|d|d|df}n|tkr|dd!}|dd!}|dd!}|dd !}|\} } d |}d |}| |d| ||d| ||d|d|d| ||| |d| ||d| ||d|d|d| ||f}n td |tttfkrHtd n|j |j |j dkrtt}n|j j ||j ||||dS(Niiiiiiiiig?sunknown transformation methodsunknown resampling filterRR(RR( R!tEXTENTtfloatt PERSPECTIVERCRRRRRR6Rt transform2(RRRRRyRR?R$Rtx0ty0tx1ty1txstystnwtswtsetnetAstAt((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt __transformerysF  +    !#!,    cCs)|j|jj|}|j|S(s3Transpose image (flip or rotate in 90 degree steps)(RRt transposeR(RRR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRVs N(8RRR7Rtformat_descriptionRzRRRRRRRRRRRRRtWEBRRRRRRRTRRRRRRRRRRRRRR R RRRRR"RR7R;R<R=R>RRBRV(((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRsh          $ 5!            1; : $  )F @    95RcBseZdZdZRS(cCstj||\}}}}||kr4|}n||krI|}n|j|_||||f|_||||f|_|j|_dS(N(RRzR6R4t_ImageCrop__cropR(RRRRIRJRKRL((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRzs      cCsM|jr-|jj|j|_d|_n|jrI|jj|jSdS(N(RYRRR7RR(R((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs    (RRRzR(((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs RcBseZRS((RR(((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRsR@cBseZRS((RR(((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR@scCstjtjdS(s+Create greyscale wedge (for debugging only)R(RRRktwedge(((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt_wedgescCsx|dkr(tjtj||St|rYddlm}|j||}ntjtj |||S(sCreate a new imagei(RN( R7RRRkRRRKRRR?(R6R4tcolorR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRs   RcGsyt|dkr2t|dtr2|d}n|dkrS|dkrS|}nt||}|j||||S(sLoad image from byte bufferiiR((RCR RiRR(R6R4RyRnRoR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR s%  cOs#tjdtddt||S(s Deprecated alias to frombytes s<fromstring() is deprecated. Please call frombytes() instead.Ri(RRRR(RoR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR.s c Gst|dkr2t|dtr2|d}n|dkr|dkr{tritjdtddn|ddf}n|dtkrt|d }|jt j |||d d|}d|_ |Snt |||||S( sLoad image from bytes or bufferiiRsthe frombuffer defaults may change in a future release; for portability, change the call to read: frombuffer(mode, size, data, 'raw', mode, 0, 1)Rii((iiN(RCR RiRRtRuntimeWarningt _MAPMODESRRRkt map_bufferR7RR(R6R4RyRnRoR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt frombufferXs %   ! c Cs>|j}|d}t|}y|d}Wntk rFd}nX|dkry,d|d|df}t|\}}Wqtk rtdqXn|}|dkrd}n|d krd }nd}||krtdn|d|df} |dk r"|j}nt|| |d|ddS(NR8tstridesiiRsCannot handle this data typeRRRRRRiisToo many dimensions.iR(ii(RRRRR( RRCRR7t_fromarray_typemapRRRR`( tobjR6tarrR8tndimRattypekeyRtndmaxR4((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt fromarrays2             sI;8s|i1si2sI;32si4sF;32Fsf4sF;64Fsf8trcCsX|dkrtdnt|rB|}tj|d}nd}|jd}txltD]d}yAt|\}}| s||r|jd|||SWqet t t fk rqeXqeWt rHxotD]d}yAt|\}}| s ||r#|jd|||SWqt t t fk r@qXqWnt ddS( s3Open an image file, without loading the raster dataRisbad modetrbRiiscannot identify image fileN(RRR-R.treadRLtIDR_R7t SyntaxErrort IndexErrorRRgRm(R0R6R2tprefixRtfactorytaccept((s//usr/lib64/python2.7/site-packages/PIL/Image.pyR.s4        cCs3|j|j|jtj|j|jS(sAlpha composite im2 over im1.(RRRktalpha_compositeR(tim1tim2((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRrs  cCs6|j|j|jtj|j|j|S(sInterpolate between images.(RRRktblendR(RsRtR ((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRus  cCs#|j}|j|d||S(sCCreate composite image by blending images using a transparency maskN(RRR7(timage1timage2RR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyt composite&s cGs|j|dS(sEvaluate image expressioni(R(RRo((s//usr/lib64/python2.7/site-packages/PIL/Image.pyteval9scCst|t|ks$d|kr3tdnx[|dD]O}|jt|krhtdn|j|djkr>tdq>q>Wtj||dj}x?tt|D]+}||j |j ||j |qW|dj |S(s=Merge a set of single band images into a new multiband image.t*swrong number of bandsis mode mismatchis size mismatch( RDRCRR6R@R4RkRRRR RR(R6RARR((s//usr/lib64/python2.7/site-packages/PIL/Image.pyRGs$cCs-|j}tj|||ft|R@RBRDRJRLRgRqRuRxRvRRRRR@R[RRRR`RhRbR.RrRuRxRyRR{R~RRR:R(((s//usr/lib64/python2.7/site-packages/PIL/Image.pyts8                                 & +    #  $  * '    5