cehua_lyf
2019-03-06 3c8ee0a8a524a6251d7d5aae2372e76fd8a99b9c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
ŒôXc@sýddlZddlZd„Zd„Zd„Zddd„Zd„Zdd„Zej    d    „Z
dd
„Z ddd „Z ej d dd„Zd„Zd„Zd„Zd„Zd„Zdd„Zdd„ZeZdddd„ZeZdS(iÿÿÿÿNcCst|ƒtdƒkrmt|ƒdkrC|\}}\}}qt|ƒdkr|\}}}}qn|}}}}||||fS(Nii((ttypetlen(tbordertleftttoptrighttbottom((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt_border"scCs4tj|ƒr0ddl}|j||ƒ}n|S(Niÿÿÿÿ(tImaget isStringTypet
ImageColortgetcolor(tcolortmodeR
((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt_color,s cCsy|jdkrtdƒ‚nW|jdkrl|jdkr_t|ƒdkr_|||}n|j|ƒStd‚dS(NtPsmode P support coming soontLtRGBis!not supported for this image mode(RR(R tNotImplementedErrorRtpointtIOError(timagetlut((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt_lut2s! icCs¶|jƒ}g}x”tdt|ƒdƒD]z}|||d!}|dk    rŽyd||<WqŽtk
rŠx|D]}d||<qsWqŽXn|r¸d}x"tdƒD]}|||}q§W||d}    xgtdƒD]Y}
|    ||
kr |    ||
}    d||
<n||
|    ||
<d}    |    dkrÚPqÚqÚW||d}    xptdddƒD]Y} |    || kr‰|    || }    d|| <n|| |    || <d}    |    dkrXPqXqXWnx"tdƒD]}
||
rÅPqÅqÅWx(tdddƒD]} || rðPqðqðW| |
kr*|jtdƒƒq+d| |
} |
| } x_tdƒD]Q}t|| | ƒ}|dkrd}n|dkr”d}n|j|ƒqPWq+Wt||ƒS(s+Maximize image contrast, based on histogramiiidiÿiÿÿÿÿgào@N(    t    histogramtrangeRtNonet    TypeErrortextendtinttappendR(RtcutofftignoreRRtlayerthtixtntcuttlothitscaletoffset((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt autocontrastLsd         
 
            cCsû|jdkst‚t|dƒ}t|dƒ}g}g}g}xtdƒD]}|j|d||d|ddƒ|j|d||d|ddƒ|j|d||d|ddƒqRW|jdƒ}t||||ƒS(sColorize a grayscale imageRRiiiÿii(R tAssertionErrorRRRtconvertR(Rtblacktwhitetredtgreentblueti((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytcolorize—s))-cCsGt|ƒ\}}}}|j|||jd||jd|fƒS(sCrop border off imageii(Rtcroptsize(RRRRRR((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyR4­scCs%|j|jtj|j|ƒ|ƒS(s%Deform image using the given deformer(t    transformR5RtMESHtgetmesh(Rtdeformertresample((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytdeform½sc    Cs&|jdkr!|jdƒ}n|j|ƒ}g}xàtdt|ƒdƒD]Æ}td    |||d!ƒ}t|ƒdkr—|jtdƒƒqOtt    j
|ƒ|dd}|sÑ|jtdƒƒqO|d}x7tdƒD])}|j ||ƒ||||}qèWqOWt ||ƒS(
sEqualize image histogramRRiiiiÿÿÿÿiÿiN( R R,RRRtfilterRRtreducetoperatortaddRR(    RtmaskR"RtbthistotstepR$R2((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytequalizeÍs 
c
Cs†t|ƒ\}}}}||jd|}||jd|}tj|j||ft||jƒƒ}    |    j|||fƒ|    S(sAdd border to imageii(RR5RtnewR Rtpaste(
RRtfillRRRRtwidththeighttout((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytexpandês *ggà?c    Cs¨t|ƒtgƒkr/|d|dg}n|ddksO|ddkr\d|d<n|ddks||ddkr‰d|d<n|dks¡|dkrªd}ntt|ƒt|jdƒdƒtt|ƒt|jdƒdƒf}|d|d|jd|dd|jd|ddf}|d|d|d|df}t|dƒt|dƒ}t|dƒt|dƒ}    ||    krÏt|    t|dƒdƒ}
|d} n(|d}
tt|dƒ|    dƒ} t|dt|d|
ƒ|dƒ} | dkr6d} nt|dt|d| ƒ|dƒ} | dkrud} n|j| | | |
| | fƒ}|j||ƒS(    s‚
    This method returns a sized and cropped version of the image,
    cropped to the aspect ratio and size that you request.
    iigð?ggà?g9î”Öÿß?ii(RRtfloatR5R4tresize(RR5tmethodtbleedt    centeringt bleedPixelstliveAreatliveSizetliveAreaAspectRatiot aspectRatiot    cropWidtht
cropHeighttleftSidettopSideRJ((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytfit
s:         $*$$  
*     *     cCs|jtjƒS(sFlip image vertically(t    transposeRtFLIP_TOP_BOTTOM(R((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytflipUscCs |jdƒS(sConvert to grayscaleR(R,(R((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt    grayscale_scCs;g}x%tdƒD]}|jd|ƒqWt||ƒS(sInvert image (negate)iiÿ(RRR(RRR2((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytinvertiscCs|jtjƒS(sFlip image horizontally(R[RtFLIP_LEFT_RIGHT(R((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytmirrorvscCsNg}dd|d}x%tdƒD]}|j||@ƒq&Wt||ƒS(s+Reduce the number of bits per color channeliiii(RRR(RtbitsRR@R2((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt    posterizes
i€cCsWg}xAtdƒD]3}||kr5|j|ƒq|jd|ƒqWt||ƒS(s!Invert all values above thresholdiiÿ(RRR(Rt    thresholdRR2((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pytsolarizes  cCs/|dkrd}n|jƒ|jj|ƒS(s PIL_usm.gblur(im, [radius])g@N(Rtloadtimt gaussian_blur(Rgtradius((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyRhs     
cCs_|dkrd}n|dkr*d}n|dkr?d}n|jƒ|jj|||ƒS(s. PIL_usm.usm(im, [radius, percent, threshold])g@i–iN(RRfRgt unsharp_mask(RgRitpercentRd((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyRj©s               
(gà?gà?(RR>RRRRR*R3R4tBILINEARR;RDRKtNEARESTRZR]R^R_RaRcReRhtgblurRjtusm(((so.\ServerPython\ZoneServerGroup\map1_8G\MapServer\MapServerData\CaptchaImage\VerificationCodePic\PIL\ImageOps.pyt<module>s*      
        K       K