ó <×ï[c@stddlmZddlmZddlZddlZddlZd„Zd„Zd„Z ddd „Z ddd d d „Z ej dd"d„Zdd„Zej d„Zejd„Zdd„Zddd„Zej dd#d„Zd„Zd„Zd„Zd„Zd„Zdd„Zdd„Zdd„Zdddd„Zdddd „Zd!„Z dS($i(tImage(t isStringTypeiÿÿÿÿNcCs†t|tƒrdt|ƒdkr:|\}}\}}qvt|ƒdkrv|\}}}}qvn|}}}}||||fS(Nii(t isinstancettupletlen(tbordertleftttoptrighttbottom((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyt_borderscCs5t|ƒr1ddlm}|j||ƒ}n|S(Ni(t ImageColor(RtR tgetcolor(tcolortmodeR ((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyt_color)s cCs||jdkrtdƒ‚nZ|jdkrl|jdkr_t|ƒdkr_|||}n|j|ƒStdƒ‚dS(NtPsmode P support coming soontLtRGBis!not supported for this image mode(RR(RtNotImplementedErrorRtpointtIOError(timagetlut((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyt_lut0s! icCs¸|jƒ}g}x–tdt|ƒdƒD]|}|||d!}|dk rŽyd||RG((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyR+s   cCs%|j|jtj|j|ƒ|ƒS(sL Deform the image. :param image: The image to deform. :param deformer: A deformer object. Any object that implements a **getmesh** method can be used. :param resample: An optional resampling filter. Same values possible as in the PIL.Image.transform function. :return: An image. (t transformRGRtMESHtgetmesh(RtdeformerR>((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytdeform3s c CsE|jdkr!|jdƒ}n|j|ƒ}g}xÿtdt|ƒdƒD]å}g|||d!D]}|rg|^qg}t|ƒdkr­|jttdƒƒƒqOtjt j |ƒ|dd}|sð|jttdƒƒƒqO|d}x7tdƒD])} |j ||ƒ||| |}qWqOWt ||ƒS( s„ Equalize the image histogram. This function applies a non-linear mapping to the input image, in order to create a uniform distribution of grayscale values in the output image. :param image: The image to equalize. :param mask: An optional mask. If given, only the pixels selected by the mask are included in the analysis. :return: An image. RRiiiiÿÿÿÿiÿi( RR/RRRRRt functoolstreducetoperatortaddR!R( RtmaskR%Rtbt_fthistotstepR'R9((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytequalizeCs *! c Cs†t|ƒ\}}}}||jd|}||jd|}tj|j||ft||jƒƒ} | j|||fƒ| S(sÖ Add border to the image :param image: The image to expand. :param border: Border width, in pixels. :param fill: Pixel fill value (a color value). Default is 0 (black). :return: An image. ii(R RGRRCRRRF( RRtfillRRRR R?R@RL((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytexpandbs *gcCsÎt|tƒs&|d|dg}n|ddksF|ddkrSd|d!     $*  $$   *  *  cCs|jtjƒS(sq Flip the image vertically (top to bottom). :param image: The image to flip. :return: An image. (t transposeRtFLIP_TOP_BOTTOM(R((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytflipÑscCs |jdƒS(si Convert the image to grayscale. :param image: The image to convert. :return: An image. R(R/(R((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyt grayscaleÛscCs;g}x%tdƒD]}|jd|ƒqWt||ƒS(sc Invert (negate) the image. :param image: The image to invert. :return: An image. iiÿ(RR!R(RRR9((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytinvertåscCs|jtjƒS(sq Flip image horizontally (left to right). :param image: The image to mirror. :return: An image. (RsRtFLIP_LEFT_RIGHT(R((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytmirroròscCsNg}dd|d}x%tdƒD]}|j||@ƒq&Wt||ƒS(sÁ Reduce the number of bits for each color channel. :param image: The image to posterize. :param bits: The number of bits to keep for each channel (1-8). :return: An image. iiii(RR!R(RtbitsRR`R9((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyt posterizeüs i€cCsWg}xAtdƒD]3}||kr5|j|ƒq|jd|ƒqWt||ƒS(s¿ Invert all pixel values above a threshold. :param image: The image to solarize. :param threshold: All pixels above this greyscale level are inverted. :return: An image. iiÿ(RR!R(Rt thresholdRR9((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytsolarize s  cCs?tjdtƒ|dkr%d}n|jƒ|jj|ƒS(s PIL_usm.gblur(im, [radius])s†PIL.ImageOps.gaussian_blur is deprecated. Use PIL.ImageFilter.GaussianBlur instead. This function will be removed in a future version.g@N(twarningstwarntDeprecationWarningRtloadtimt gaussian_blur(R‚tradius((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyRƒs   cCstjdtƒt||ƒS(s PIL_usm.gblur(im, [radius])s~PIL.ImageOps.gblur is deprecated. Use PIL.ImageFilter.GaussianBlur instead. This function will be removed in a future version.(R~RR€Rƒ(R‚R„((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytgblur1scCsotjdtƒ|dkr%d}n|dkr:d}n|dkrOd}n|jƒ|jj|||ƒS(s. PIL_usm.usm(im, [radius, percent, threshold])s„PIL.ImageOps.unsharp_mask is deprecated. Use PIL.ImageFilter.UnsharpMask instead. This function will be removed in a future version.g@i–iN(R~RR€RRR‚t unsharp_mask(R‚R„tpercentR|((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyR†>s       cCs#tjdtƒt||||ƒS(s. PIL_usm.usm(im, [radius, percent, threshold])s{PIL.ImageOps.usm is deprecated. Use PIL.ImageFilter.UnsharpMask instead. This function will be removed in a future version.(R~RR€R†(R‚R„R‡R|((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pytusmTscCs3tjdtƒ|jƒ|j|jj|ƒƒS(sF Blur the image by setting each pixel to the average value of the pixels in a square box extending radius pixels in each direction. Supports float radius of arbitrary size. Uses an optimized implementation which runs in linear time relative to the size of the image for any radius value. :param image: The image to blur. :param radius: Size of the box in one direction. Radius 0 does not blur, returns an identical image. Radius 1 takes 1 pixel in each direction, i.e. 9 pixels in total. :return: An image. s|PIL.ImageOps.box_blur is deprecated. Use PIL.ImageFilter.BoxBlur instead. This function will be removed in a future version.(R~RR€Rt_newR‚tbox_blur(RR„((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyRŠas  (gà?gà?(gà?gà?(!R Rt_utilRR^R\R~R RRRR-R=tNEARESTRQRRR+tBILINEARR[ReRgRrRuRvRwRyR{R}RƒR…R†RˆRŠ(((s,/tmp/pip-build-SKekGm/pillow/PIL/ImageOps.pyts8     LT,  ^