8rEc@sdZyddkZWnej o eZnXdfdYZyedWnej onXyddkZeZ[WnPej oDZeZe ed djoeoei de nnXddk Z ddk Z ddkZddkZddkZdd klZlZlZyeed Zd ZWnej od ZnXd ZdZdZddklZlZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ!dZ,dZ-dZ.Z/dZ0Z1dZ!dZ,dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9gZ:hZ;hZ<hZ=hZ>hdddffd<dddffd<dddffd<dddffd<dddffd<dddddffd<ddddddffd <dddddd!ffd"<ddd#d$d%d&ffd'<ddd%d(d)ffd*YZQd?ZRd@fdAYZSdBeSfdCYZTdDZUddEZVdFdGZWdFdHZXedIZYdJdKZZdLZ[dMZ\dNZ]dOZ^edPZ_dQZ`dRZadSZbeedTZcdS(Us1.1.6iNt_imaging_not_installedcBseZdZRS(cCstddS(Ns&The _imaging C module is not installed(t ImportError(tselftid((s Image.pyct __getattr__#s(t__name__t __module__R(((s Image.pycR!stFixTkisModule use of pythonscThe _imaging extension was built for another version of Python; most PIL functions will be disabled(tIntTypet StringTypet TupleTypetcCst|tp t|tS(N(t isinstanceR tUnicodeStringType(tt((s Image.pyct isStringTypeRscCs t|tS(N(R R (R((s Image.pycRUscCs t|tS(N(R R (R((s Image.pyct isTupleType[scCs t|dS(Ntim(thasattr(R((s Image.pyct isImageTypeascCst|otii|S(N(Rtostpathtisdir(tf((s Image.pyct isDirectoryhs(t isNumberTypetisSequenceTypeiiiiitLt1tItFtRGBtPtRtGtBtXtRGBXtAtRGBAtCtMtYtKtCMYKtCbtCrtYCbCrtlittlets|b1s|u1s%si4s%sf4cCsY|iddd}t|i\}}|djo||fSn||f|fSdS(Ni(tsizet _MODE_CONVtmodetNone(Rtshapettyptextra((s Image.pyct_conv_type_shapes  sI;16sI;16BcCsti|iS(N(t ImageModetgetmodetbasemode(R5((s Image.pyct getmodebasescCsti|iS(N(R;R<tbasetype(R5((s Image.pyct getmodetypescCsti|iS(N(R;R<tbands(R5((s Image.pyctgetmodebandnamesscCstti|iS(N(tlenR;R<RA(R5((s Image.pyct getmodebands scCstdjodSnyddk}Wntj onXyddk}Wntj onXyddk}Wntj onXyddk}Wntj onXyddk}Wntj onXdadS(s"Load standard file format drivers.iNi(t _initializedtBmpImagePluginRtGifImagePlugintJpegImagePlugintPpmImagePlugintPngImagePlugin(RFRGRHRIRJ((s Image.pyctpreinits. cCs~tdjodSnh}ti}y|tiitg}Wntj onXxtt|D]}tii |}|i |oqgnxti |D]}|ddjotii |\}}yBtii d|zt|ttgWdtid=XWqPtj o&todG|GdGtiGHqLqPXqqWd||s:  !cCs|djo d}nt|p |f}ny/tt|d}t||f||SWn#tj otd|nXdS(Nt_decodersdecoder %s not available((R6RtgetattrtcoretapplytAttributeErrortIOError(R5t decoder_nametargsR9tdecoder((s Image.pyct _getdecoderis    cCs|djo d}nt|p |f}ny/tt|d}t||f||SWn#tj otd|nXdS(Nt_encodersencoder %s not available((R6RRfRgRhRiRj(R5t encoder_nameRlR9tencoder((s Image.pyct _getencoderys    t_EcBs,eZdZdZdZdZRS(cCs ||_dS(N(tdata(RRt((s Image.pyct__init__scCs|t|fS(N(Rs(Rtother((s Image.pyct __coerce__scCst|id|ifS(Nt__add__(RsRt(RRv((s Image.pycRxscCst|id|ifS(Nt__mul__(RsRt(RRv((s Image.pycRys(RRRuRwRxRy(((s Image.pycRss   c CsBdg}|t|i}y}|\}}}||jo(|djot|o|dfSn||jo(|djot|od|fSnWntj onXyk|\\}}}}}||joB|djo5t|o(|djot|o||fSnWntj onXtddS(NtstubRygRxg?sillegal expression(RsRtRt TypeErrort ValueError(texprRzRttatbtctdRc((s Image.pyct_getscaleoffsets$ '''tImagecBs$eZd5Zd5ZdZdZeZdZd5d5dZ dZ ddZ ddZ dd Z d Zd Zd5d5d5ed d Zd ddd5dZdZd5dZdZd5dZdZdZdZd dZd5dZdZdZdZdZdZ d5d5dZ!d5dZ"d5d5d Z#d5d!Z$d"Z%d#d$d%Z&d&d'Z'd(Z(e)d)Z*e)dd*Z+d5d+Z,d,Z-d5d5d-Z.d.Z/d/Z0e)d0Z1d5e)d1d2Z2e)d1d3Z3d4Z4RS(6cCsCd|_d|_d|_d|_h|_t|_d|_dS(NR i(ii( R6RR5R3tpalettetinfotNORMALtcategorytreadonly(R((s Image.pycRus      cCst}||_|i|_|i|_|i|_|idjoti|_ny|ii|_WnCtj o7h|_x)|iD]\}}||i|tKeyError(RR5RttditherRtcolorsR((s Image.pycR~s6       icCs|i|o|i|idjotdn|idjo |idjotdn|iidd|i}|i|Sn|ii|||}|i|S(NR sbad mode for palette imageRRs7only RGB or L mode images can be quantized to a palettei(RR5R|RRt _makeselfRR(RRtmethodtkmeansRR((s Image.pycRs    cCs&|i|ii}|i|S(sCopy raster data(RRRR(RR((s Image.pycRs cCs2|i|djo|iSnt||S(sCrop region from imageN(RR6Rt _ImageCrop(Rtbox((s Image.pyctcrops  cCsdS(sConfigure image decoderN((RR5R3((s Image.pyctdraftscCs@|djo |}n|i|i|ii||dS(Ni(R6RRRtexpand(Rtxmargintymargin((s Image.pyct_expands   cCs|iddkl}t||p |}n|iidjo|i|i|iSng}xEt|iiD]1}|i |i|i|ii |qWt |i |S(s!Apply environment filter to imagei(tFilteri( Rt ImageFilterRR RRARRQtrangeRtgetbandtmergeR5(RRQRtimsR((s Image.pycRQs  /cCsti|iiS(sGet band names(R;R<R5RA(R((s Image.pyctgetbandsscCs|i|iiS(s:Get bounding box of actual data (non-zero pixels) in image(RRtgetbbox(R((s Image.pycR,s cCs|i|idjou|ii}g}x:tdD],}||o|i|||fq<q<Wt||jodSn|Sn|ii|S(s(Get colors from image, up to given limitRRR i(RRR N( RR5Rt histogramRRRCR6t getcolors(Rt maxcolorsthtoutti((s Image.pycR:s   cCs2|i|dj o|ii|Sn|iS(s"Get image data as sequence object.N(RR6RR(Rtband((s Image.pycRYs  cCsz|i|iidjoPg}x9t|iiD]%}|i|ii|iq6Wt|Sn|iiS(sGet min/max valuei(RRRARRRt getextremattuple(RtextremaR((s Image.pycRis #cCs|i|iiS(s.Get PyCObject pointer to internal image memory(RRtptr(R((s Image.pyctgetimys cCsB|iytt|iiSWntj o dSnXdS(sGet palette contents.N(RtmaptordRt getpaletteR|R6(R((s Image.pycRs  cCs|i|ii|S(sGet pixel value(RRtgetpixel(Rtxy((s Image.pycRs cCs;|i|ii\}}tt|tt|fS(sGet projection to x and y axes(RRt getprojectionRR(Rtxty((s Image.pycRs cCs|i|o$|i|iid|iSn|idjo1|djo|i}n|ii|Sn|iiS(sTake histogram of imageiRR(ii(RRN(RRRR5R6R(RtmaskR((s Image.pycRs   cCs@totidtddnddk}|i|||S(sA(deprecated) Offset image in horizontal and/or vertical directions7'offset' is deprecated; use 'ImageChops.offset' insteadt stackleveliiN(twarningstwarntDeprecationWarningt ImageChopstoffset(RtxoffsettyoffsetR((s Image.pycRs  cCst|o|djo|}d}n|djod |i}nt|djolt|o |i}n't|o |i}n td||d|d|d|df}nt|o%ddk}|i||i}nrt|od|i |i|ijo:|idjp|id jo|i |i}q]n|i }n|i |i o|i n|o'|i |i i|||i n|i i||dS( sPaste other image into regioniis,cannot determine region size; use 4-item boxiiNRR'tRGBa(ii(sRGBAsRGBa(RR6R3RCR|Rt ImageColortgetcolorR5RRRRRtpaste(RRRRR3R((s Image.pycRs:       ,         cCs|it|pe|idjo2t|\}}|i|ii||Snt|td|ii }n|idjot dn|i|ii ||S(sMap image through lookup tableRsI;16Ris+point operation not supported for this mode(RsI;16R( RRR5RRRtpoint_transformRRRAR|tpoint(RtlutR5tscaleR((s Image.pycRCs   #c Cs|i|io|in|id joyt|id}y|ii|WnNttfj o<|ii |}|id jo tn||_nX|ii|_Wqt tfj otdqXn|idjo d}nd}t |oQ|id jotdn|i|idjo|i d}qnMy|ii ||Wn.ttfj ot d|i|}nXd S|ii|i|d S( sSet alpha layertLAR'R&sillegal image modeiiRRN(sLAsRGBA(sLAsRGBA(RR(RRRR5R>RtsetmodeRiR|RRRtfillbandRR3tputband(RtalphaR5RR((s Image.pyctputalpha`s>      g?gcCs<|i|io|in|ii|||dS(s.Put data from a sequence object into an image.N(RRRRtputdata(RRtRR((s Image.pycRs  RcCs|i|idjotdnt|ptitt|d}nd|_ti |||_ d|i _|idS(sPut palette data into an image.RR sillegal image modeR RN(RR ( RR5R|RRRRtchrRRR(RRtR((s Image.pycRs    cCs5|i|io|in|ii||S(sSet pixel value(RRRRtputpixel(RRtvalue((s Image.pycRs  cCs|ttttfjotdn|i|idjo t}n|tjo?y|ii||}Wqt j otdqXn|ii ||}|i |S(s Resize imagesunknown resampling filterRR sunsupported resampling filter(RR ( tNEARESTtBILINEARtBICUBICt ANTIALIASR|RR5RtstretchRitresizeR(RR3tresampleR((s Image.pycRs   c Cs|oddk}| |id}|i||i|d|i| |i|dg}|d}|i\}}g} g} xad|df||fd|ffD];\} } || | \} } | i| | i| qWt|it| |i t | }t|it| |i t | }||d|d\} } |idd| |d<|id d| |d <|i ||ft |Sn|t ttfjotd n|i|idjo t }n|i|ii||S(s8Rotate image. Angle given as degrees counter-clockwise.iNigc SsB|\}}}}}}||||||||||fS(N(( RRt.2R~RRRRcR((s Image.pyct transformsig@iiisunknown resampling filterRR (ii(RR (tmathtpitcostsinR3RtinttceilRtfloortminRtAFFINERRRR|RR5RRtrotate( RtangleRRRtmatrixRtwRtxxtyyRR((s Image.pycR s4 " %  ..  c Kst|o |}n4t|dot|io |i}nd}|i||_d|_ttit i i |d}|p_yt |}Wqt j o>tyt |}Wqt j ot |qXqXnytti|}Wn-t j o!ttti|}nXt|o(ddk}|i|d}d}nd}z||||Wd|o|inXdS( sSave image to file or streamRR iiNtwbi((RRRRt encoderinfot encoderconfigRKRtlowerRRRUt EXTENSIONRRdR]tuppert __builtin__topentclose( RtfpRtparamstfilenametextt save_handlerRR((s Image.pycRPsB          cCs|djo tndS(s$Seek to given frame in sequence fileiN(tEOFError(Rtframe((s Image.pyctseeks cCst|||dS(s'Display image (for debug purposes only)N(t_showxv(Rttitletcommand((s Image.pyctshowscCsYg}|ix<t|iiD](}|i|i|ii|q#Wt|S(sSplit image into bands(RRRRARRRR(RRR((s Image.pyctsplits  &cCsdS(sReturn current frame numberi((R((s Image.pycttellscCsA|i\}}||djo)t||d|d}|d}n||djo)t||d|d}|d}n||f}||ijodSn|id||iy|i||}Wn9tj o-|tjon|i|t}nX|i |_ |i |_ ||_d|_ dS(s9Create thumbnail representation (modifies image in place)iiN( R3RRR6RRR|RRRR5R(RR3RRRR((s Image.pyct thumbnails,      ic Csddk}t||io|i\}}n|djotdnt|i|d}|tjo7xT|D](\}} |i ||t | ||q{Wn!|i d|||||||S(sTransform imageiNsmissing method datai(ii( tImageTransformR t TransformRR6R|RR5tMESHt_Image__transformertQUAD( RR3RRtRtfillR/RRtquad((s Image.pycRs    $ cCs|d|d}|d|d}|tjo4|d|d|d|d|d|df}n|tjol|\} } } } t| | |} t| | |}t}| | d| d| |dd|f}nO|tjoB|d|d|d|d|d|d|d|df}n|tjo|dd!}|dd!}|dd!}|dd !}|\} } d |}d |}| |d| ||d| ||d|d|d| ||| |d| ||d| ||d|d|d| ||f}n td |tttfjotd n|i |i |i djo t}n|i i ||i ||||dS(Niiiiiiiiig?sunknown transformation methodsunknown resampling filterRR (RR ( RtEXTENTtfloatt PERSPECTIVER3R|RRRRR5Rt transform2(RRRRRtRR4RRtx0ty0tx1ty1txstystnwtswtsetnetAstAt((s Image.pyct __transformer,sF  ,    !#!-    cCs)|i|ii|}|i|S(s3Transpose image (flip or rotate in 90 degree steps)(RRt transposeR(RRR((s Image.pycRGbs N(5RRR6Rtformat_descriptionRuRRRRRRRRRRtWEBRRRRRRRQRRRRRRRRRRRRRRRRRRRRRR'R+R,R-R.RR2RG(((s Image.pycRsb    %     +            1;  :   )E A    95RcBseZdZdZRS(cCsti||\}}}}||jo |}n||jo |}n|i|_||||f|_||||f|_|i|_dS(N(RRuR5R3t_ImageCrop__cropR(RRRR:R;R<R=((s Image.pycRuns      cCs3|io%|ii|i|_d|_ndS(N(RJRRR6(R((s Image.pycRs (RRRuR(((s Image.pycRls cCstitidS(s+Create greyscale wedge (for debugging only)R(RRRgtwedge(((s Image.pyct_wedgescCs{|djo titi||Snt|o"ddk}|i||}ntiti|||S(sCreate a new imageiN( R6RRRgRRRRR4(R5R3tcolorR((s Image.pycRs     RcGs|t|djot|do|d}n|djo|djo |}nt||}|i||||S(sLoad image from stringiiR((RCRRR(R5R3RtRkRlR((s Image.pycRs$ cGst|djot|do|d}n|djo|djo4totidtddn|ddf}n|dtjoGt|d }|iti |||d d|}d|_ |Sqnt t |||||fS( s Load image from string 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(RCRRRtRuntimeWarningt _MAPMODESRRRgt map_bufferR6RRhR(R5R3RtRkRlR((s Image.pyct frombuffers $  !  c Cs|i}|d}t|}y|d}Wntj o d}nX|djo|d}|ddjp|dtjp|ddjptd n|d }|d jo d }qG|d jo d}qG|djo d}qG|d jo d}qG|djo d}qG|djo d}qGtdnd}d}|djo d }n|djo d}n||jotdn|d ddd} |dj o|i}nt|| |d|ddS(NR7tstridesRit|itu1tb1ti4tf4scannot handle data-typeiRRRRiRiR'sDo not understand data.R sToo many dimensions.iR(su1sb1si4sf4(RRRR R( RRCRR6t_ENDIANR{R|RRQ( tobjR5tarrR7tndimRRRtndmaxtbad_dimsR3((s Image.pyct fromarraysL      "                   trc Css|djotdnt|o(ddk}|}|i|d}nd}|id}txttD]l}yGt|\}}| p ||o|id|||SnWqut t t fj oquXquWt xttD]l}yGt|\}}| p ||o|id|||SnWqt t t fj oqXqWt d dS( s3Open an image file, without loading the raster dataR_sbad modeiNtrbR iiscannot identify image file(R|RRRtreadRKtIDR\R't SyntaxErrort IndexErrorR{RdRj(R R5RR"tprefixRtfactorytaccept((s Image.pycRWs:       cCs6|i|i|iti|i|i|S(sInterpolate between images.(RRRgtblendR(tim1tim2R((s Image.pycRhs  cCs#|i}|i|d||S(sCCreate composite image by blending images using a transparency maskN(RRR6(timage1timage2RR((s Image.pyct composites cGs|i|dS(sEvaluate image expressioni(R(RRl((s Image.pyctevalscCst|t|jp d|jotdnx_|dD]S}|it|jotdn|i|dijotdqAqAWti||di}x?tt|D]+}||i |i ||i |qW|di |S(s=Merge a set of single band images into a new multiband image.t*swrong number of bandsis mode mismatchis size mismatch( RDRCR|R5R@R3RgRRRRRR(R5RARR((s Image.pycRs& cCs0ti|}ti|||ft|RRtsystem(RR)R*RtbaseRb((s Image.pycR( s.   (dtVERSIONRRR6RRWt_imagingRgRtstrRRNR;RRRRMttypesRR R ttypetunicodeR RRPRRRtoperatorRRRZtNONEtFLIP_LEFT_RIGHTtFLIP_TOP_BOTTOMt ROTATE_90t ROTATE_180t ROTATE_270RR6R8R3R1RRtLINEARRtCUBICRtORDEREDt RASTERIZERRIRRtSEQUENCEt CONTAINERRbR\RqR]Rt _MODEINFOt byteorderRXR4R:tkeystMODEStsortROR>R@RBRDRERKRdRnRrRsRRRRLRRRQR^RRhRmRnRRpRsRuRwR((((s Image.pycss     $            & +   #  $ / ' < <