<[c@s ddlmZmZmZmZddlmZddlZddlZddl Z ej e Z de fdYZdefdYZd efd YZed d d d d ZyQddlmZeeedekredeedeefnWnek rZeZeejdrWejde nxeejdrejeee nJdeekrejde n%deekrejde nnXyddlZWn#ek r ddlZeZnXddlm Z ddl!m"Z"ddlm#Z#m$Z$m%Z%ddl&Z&ddl'Z'ddl(Z(ddl)Z)ddl*Z*ddl+Z+yddl,m-Z-Wn!ek rddl.m-Z-nXe/e'dZ0yddl1Z1e2Z3Wnek re4Z3nXyddl5m6Z6e2Z7WnEek rhyddl8m6Z6e2Z7Wnek rde4Z7nXnXdZ9dZ:dZ;dZ<d Z=d Z>d Z?d!Z@d"ZAdZBdZCd ZDd ZEd ZFdZGZ:d ZHd ZIZJd!ZKd ZLZMdZNZOdZGZ:dZPd ZQd ZRdZSdZTdZUdZVd ZWd ZXdZYdZZd Z[e/ed#rej\Z\ej]Z]ej^Z^ej_Z_ej`Z`ngZaiZbiZciZdiZeiZfiZgiZhi d$d$d%ffd%6d$d$d$ffd$6d$d&d&ffd&6d$d'd'ffd'6d(d$d)ffd)6d(d$d*d+d,ffd(6d(d$d*d+d,d-ffd.6d(d$d*d+d,d/ffd06d(d$d1d2d3d4ffd56d(d$d3d6d7ffd86d(d$d$d/d,ffd96d(d$d:d;d<ffd=6Zie'jjd>krd?Zknd@ZkidAefd%6dBefd$6dBd fdC6ekdDefd&6ekdEefd'6dBefd)6dBd fd(6dBd fd.6dBd fd06dBd fd56dBd fd86dBd fd96dBd fd=6dFefdG6dHefdI6dFefdJ6dKefdL6dMefdN6dKefdO6dPefdQ6dRefdS6dPefdT6dUefdV6dWefdX6dUefdY6ZldZZmeneiZod$d)d.d0d5dGdJdIfZpd[Zqd\Zrd]Zsd^Ztdaud_Zvd`ZwfdaZxfdbZydcZzddefdeYZ{dfZ|dgefdhYZ}diefdjYZ~dkefdlYZdmZdnZddoZdpdqZdrZdpdsZedtZduZdvZid%dwfddfdAf6d$d$fddfdBf6d&dxfddfdyf6d&dGfddfdFf6d&dIfddfdHf6d&dLfddfdKf6d&dNfddfdMf6d&dQfddfdPf6d&dSfddfdRf6d&dVfddfdUf6d&dXfddfdWf6d'dzfddfd{f6d'd|fddfd}f6d'd~fddfdf6d'dfddfdf6dCdCfddd fdBf6d(d(fddd fdBf6d0d0fddd fdBf6Zd&d&feddfekdDfs|b1s|u1tLAti4tf4su2sI;16BsI;16Lsi2sI;16BSsI;16LSsu4sI;32BsI;32Lsi4sI;32BSsI;32LScCsbt|j\}}|dkr=|jd|jdf|fS|jd|jd|f|fSdS(Nii(t _MODE_CONVtmodetNonetsize(Rttyptextra((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_conv_type_shape*s cCstj|jS(s% Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data. :param mode: Input mode. :returns: "L" or "RGB". :exception KeyError: If the input mode was not a standard mode. (Rtgetmodetbasemode(R=((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt getmodebase9s cCstj|jS(s  Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands. :param mode: Input mode. :returns: "L", "I", or "F". :exception KeyError: If the input mode was not a standard mode. (RRCtbasetype(R=((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt getmodetypeFs cCstj|jS(s Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band. :param mode: Input mode. :returns: A tuple containing band names. The length of the tuple gives the number of bands in an image of the given mode. :exception KeyError: If the input mode was not a standard mode. (RRCtbands(R=((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytgetmodebandnamesRs cCsttj|jS(s Gets the number of individual bands for this mode. :param mode: Input mode. :returns: The number of bands in this mode. :exception KeyError: If the input mode was not a standard mode. (tlenRRCRH(R=((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt getmodebandsascCstdkrdSyddlm}Wntk r7nXyddlm}Wntk r_nXyddlm}Wntk rnXyddlm}Wntk rnXyddlm}Wntk rnXdadS(s-Explicitly load standard file format drivers.iN(tBmpImagePlugin(tGifImagePlugin(tJpegImagePlugin(tPpmImagePlugin(tPngImagePlugin(t _initializedtRLR RMRNRORP(RLRMRNRORP((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytpreinitrs.      cCstdkrdSxhtD]`}y1tjd|td|ttgWqtk rv}tjd||qXqWtst rdadSdS(sw Explicitly initializes the Python Imaging Library. This function loads all available file format drivers. iis Importing %ssPIL.%ssImage: failed to import %s: %siN( RQRtloggertdebugt __import__tglobalstlocalsR tOPENtSAVE(tpluginte((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytinits  ! cCs|dkrd}nt|ts0|f}nyt|}||||SWntk rbnXy(tt|d}||||SWn!tk rtd|nXdS(Nt_decodersdecoder %s not available(( R>t isinstancettupletDECODERStKeyErrortgetattrtcoretAttributeErrortIOError(R=t decoder_nametargsRAtdecoder((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt _getdecoders      cCs|dkrd}nt|ts0|f}nyt|}||||SWntk rbnXy(tt|d}||||SWn!tk rtd|nXdS(Nt_encodersencoder %s not available(( R>R_R`tENCODERSRbRcRdReRf(R=t encoder_nameRhRAtencoder((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt _getencoders      cCst|tr|St|S(N(R_t_E(tvalue((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytcoerce_esRpcBs#eZdZdZdZRS(cCs ||_dS(N(tdata(R Rs((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt__init__scCst|jdt|jfS(Nt__add__(RpRsRr(R tother((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRuscCst|jdt|jfS(Nt__mul__(RpRsRr(R Rv((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRws(RRRtRuRw(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRps  cCs?dg}|t|j}y{|\}}}||krd|dkrdt|tjrd|dfS||kr|dkrt|tjrd|fSWntk rnXyn|\\}}}}}||kr|dkrt|tjr|dkrt|tjr||fSWntk r.nXtddS(NtstubRwgRug?sillegal expression(RpRsR_tnumberstNumbert TypeErrort ValueError(texprRxRstatbtctdR\((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_getscaleoffsets$ * * * tImagecBsDeZdZdNZdNZeZdZe dZ e dZ e dZ dZ dZdZdZejjd krd Znd Zd ZdNdNd ZdZdZdZdZe dZdZdZddZdZ ddZ!ddZ"dZ#dZ$dZ%dNdNdNe&ddZ'ddNd dNd!Z(d"Z)e)Z*dNd#Z+d$Z,d%Z-dNd&Z.d'Z/d(Z0d)Z1dd*Z2dNd+Z3d,Z4d-Z5d.Z6d/Z7d0Z8dNdNd1Z9dNd2Z:dNdNd3Z;dOdPd4Z<dNd5Z=d6Z>d7d8d9Z?d:d;Z@d<ZAdNd=ZBeCdNd>ZDeCd dNdNdNd?ZEdNd@ZFdAZGdNdNdBZHdCZIdDZJdEZKeLdFZMdNeCdGdNdHZNeCdGdIZOdJZPdKZQdLZRdMZSRS(QsD This class represents an image object. To create :py:class:`~PIL.Image.Image` objects, use the appropriate factory functions. There's hardly ever any reason to call the Image constructor directly. * :py:func:`~PIL.Image.open` * :py:func:`~PIL.Image.new` * :py:func:`~PIL.Image.frombytes` cCsLd|_d|_d|_d|_i|_t|_d|_d|_ dS(NRRi(ii( R>RR=t_sizetpalettetinfotNORMALtcategorytreadonlytpyaccess(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRts       cCs |jdS(Ni(R?(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytwidthscCs |jdS(Ni(R?(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytheight!scCs|jS(N(R(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR?%scCst}||_|j|_|j|_|jdkry|jrW|jj|_qyddlm}|j|_n|j j|_ |S(NR!tPAi(t ImagePalette(R!R( RRR=R?RRtcopyRRRR(R RtnewR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_new)s     cCs|S(N((R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt __enter__8scGs|jdS(N(tclose(R Rh((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt__exit__;scCswy|jjd|_Wn#tk r?}tjd|nXt|ddr^d|_ntt d|_ dS(s Closes the file pointer, if possible. This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is only required to close images that have not had their file read and closed by the :py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for more information. sError closing: %stmapsOperation on closed imageN( tfpRR>t ExceptionRTRURcRRR|R(R tmsg((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR>s    icCsMt|dr@t|dr@|jr@|jr@|jjnd|_dS(NRt _exclusive_fp(RRRRR>(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt__del__YscCs2|j|jj|_d|_d|_dS(Ni(tloadRRR>RR(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_copy_s  cCs$|jr|jn |jdS(N(RRR(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_ensure_mutablees  cKsddl}d}|r%d|}n|sP|j|\}}tj|n"|}|j|sr||}n|j| s|dkr|jj|n|j||||S(NiRRt.tPPM( ttempfiletmkstemptosRtendswithRRtsave_ppmtsave(R tfiletformattoptionsRtsuffixtftfilename((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_dumpks    cCst|to|jj|jjko|j|jko|j|jko|j|jko|j|jko|j|jko|j |j ko|j |j kS(N( R_Rt __class__RR=R?RRRt getpalettettobytes(R Rv((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt__eq__scCs||k}| S(N((R Rvteq((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt__ne__s cCs=d|jj|jj|j|jd|jdt|fS(Ns(<%s.%s image mode=%s size=%dx%d at 0x%X>ii(RRRR=R?R (R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt__repr__scCs3ddlm}|}|j|d|jS(s[ iPython display hook support :returns: png version of the image as bytes i(tBytesIOtPNG(tioRRtgetvalue(R RR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt _repr_png_s cCsri}t|\}}||d<||dtrawmodeRR_tinttputpalettealphatputpalettealphastHAS_CFFItUSE_CFFI_ACCESSRRRRRRt pixel_access(R R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR)s&         cCsdS(ss Verifies the contents of a file. For data read from a file, this method attempts to determine if the file is broken, without actually decoding the image data. If this method finds any problems, it raises suitable exceptions. If you need to load the image after using this method, you must reopen the image file. N((R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytverifyMs icCs|j| rA|jdkrA|jr8|jj}qAd}n| s^||jkrh| rh|jS|jjddk }|r|dkrtdn|jj ||}|j |}|r|jj dkr|jd} d} |dkr| || } n_t |dkrpt gtdt | D](} | || d | d d !| ^q<} n| |jdiiR(s"Palette images with Transparency s( expressed in bytes should be converted sto RGBA imagesis2Couldn't allocate a palette color for transparencysTransparency for P mode shoulds be bytes or int(Rs Couldn't allocate palette entry sfor transparencyN(RR (RR (RR R!(RR R!(ii(ii(RR (ii(*RR=RRRtgetR>R|Rtconvert_matrixRRHRJR`trangetquantizetFalsetconvert_transparentR_tbytestwarningstwarnRRRdRRtgetcolortputpixeltconverttgetpixelRRRtADAPTIVERRRRRtFLOYDSTEINBERGRERb(R R=tmatrixtditherRtcolorsthas_transparencyRRRRtittrnst delete_trnstnew_imRttrns_imR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRXs+        G    !  !            icCs|j|d kr7d}|jdkr7d}q7n|jdkre|dkretddn|r|j|jdkrtdn|jd kr|jd krtd n|jjdd |j}|j|S|j|jj|||S(s Convert the image to 'P' mode with the specified number of colors. :param colors: The desired number of colors, <= 256 :param method: 0 = median cut 1 = maximum coverage 2 = fast octree 3 = libimagequant :param kmeans: Integer :param palette: Quantize to the palette of given :py:class:`PIL.Image.Image`. :returns: A new image iR(iis:Fast Octree (method == 2) and libimagequant (method == 3) s5are the only valid methods for quantizing RGBA imagesR!sbad mode for palette imageR Rs7only RGB or L mode images can be quantized to a paletteiN(ii(RR>R=R|RRRR(R RtmethodtkmeansRR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs&       cCs |j|j|jjS(s Copies this image. Use this method if you wish to paste things into an image, but still retain the original. :rtype: :py:class:`~PIL.Image.Image` :returns: An :py:class:`~PIL.Image.Image` object. (RRRR(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR;s cCs<|dkr|jS|j|j|j|j|S(s Returns a rectangular region from this image. The box is a 4-tuple defining the left, upper, right, and lower pixel coordinate. See :ref:`coordinate-system`. Note: Prior to Pillow 3.4.0, this was a lazy operation. :param box: The crop rectangle, as a (left, upper, right, lower)-tuple. :rtype: :py:class:`~PIL.Image.Image` :returns: An :py:class:`~PIL.Image.Image` object. N(R>RRRt_cropR(R tbox((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytcropHs   cCsgtttt|\}}}}t||t||f}t||j||||fS(s] Returns a rectangular region from the core image object im. This is equivalent to calling im.crop((x0, y0, x1, y1)), but includes additional sanity checks. :param im: a core image object :param box: The crop rectangle, as a (left, upper, right, lower)-tuple. :returns: A core image object. (RRtroundtabst_decompression_bomb_checkR(R RRtx0ty0tx1ty1tabsolute_values((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR[s $  cCsdS(s Configures the image file loader so it returns a version of the image that as closely as possible matches the given mode and size. For example, you can use this method to convert a color JPEG to greyscale while loading it, or to extract a 128x192 version from a PCD file. Note that this method modifies the :py:class:`~PIL.Image.Image` object in place. If the image has already been loaded, this method has no effect. Note: This method is not implemented for most images. It is currently implemented only for JPEG and PCD images. :param mode: The requested mode. :param size: The requested size. N((R R=R?((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytdraftoscCs>|dkr|}n|j|j|jj||dS(Ni(R>RRRtexpand(R txmargintymargin((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_expands   cCsddlm}|jt|tr5|}nt|dsWtddnt||j}|jj dks|r|j |j |jSg}xEt |jj D]1}|j |j |j |jj|qWt|j|S(s Filters this image using the given filter. For a list of available filters, see the :py:mod:`~PIL.ImageFilter` module. :param filter: Filter kernel. :returns: An :py:class:`~PIL.Image.Image` object. i(t ImageFiltertfilters-filter argument should be ImageFilter.Filter sinstance or class(RRRRR_RRR{tMultibandFilterRRHRRRRtgetbandtmergeR=(R RRt multibandtimsR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs   /cCstj|jjS(s Returns a tuple containing the name of each band in this image. For example, **getbands** on an RGB image returns ("R", "G", "B"). :returns: A tuple containing band names. :rtype: tuple (RRCR=RH(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytgetbandsscCs|j|jjS(sQ Calculates the bounding box of the non-zero regions in the image. :returns: The bounding box is returned as a 4-tuple defining the left, upper, right, and lower pixel coordinate. See :ref:`coordinate-system`. If the image is completely empty, this method returns None. (RRtgetbbox(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs cCs|j|jdkr|jj}g}x8tdD]*}||r;|j|||fq;q;Wt||krdS|S|jj|S(s Returns a list of colors used in this image. :param maxcolors: Maximum number of colors. If this number is exceeded, this method returns None. The default limit is 256 colors. :returns: An unsorted list of (count, pixel) values. RRR!i(RRR!N( RR=Rt histogramRRRJR>t getcolors(R t maxcolorsthtoutR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs  cCs-|j|dk r&|jj|S|jS(s Returns the contents of this image as a sequence object containing pixel values. The sequence object is flattened, so that values for line one follow directly after the values of line zero, and so on. Note that the sequence object returned by this method is an internal PIL data type, which only supports certain sequence operations. To convert it to an ordinary sequence (e.g. for printing), use **list(im.getdata())**. :param band: What band to return. The default is to return all bands. To return a single band, pass in the index value (e.g. 0 to get the "R" band from an "RGB" image). :returns: A sequence-like object. N(RR>RR(R tband((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs  cCsu|j|jjdkrhg}x9t|jjD]%}|j|jj|jq5Wt|S|jjS(s& Gets the the minimum and maximum pixel values for each band in the image. :returns: For a single-band image, a 2-tuple containing the minimum and maximum pixel value. For a multi-band image, a tuple containing one 2-tuple for each band. i(RRRHRRRt getextremaR`(R textremaR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR!s # cCs|j|jjS(sr Returns a capsule that points to the internal image memory. :returns: A capsule object. (RRtptr(R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytgetims cCsf|jyCtr&t|jjSg|jjD]}t|^q6SWntk radSXdS(s Returns the image palette as a list. :returns: A list of color values [r, g, b, ...], or None if the image has no palette. N(RRtlistRRRR|R>(R R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs * cCs3|j|jr#|jj|S|jj|S(s  Returns the pixel value at a given position. :param xy: The coordinate, given as (x, y). See :ref:`coordinate-system`. :returns: The pixel value. If the image is a multi-layer image, this method returns a tuple. (RRRR(R txy((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs  cCs[|j|jj\}}g|D]}t|^q&g|D]}t|^qBfS(s Get projection to x and y axes :returns: Two sequences, indicating where there are non-zero pixels along the X-axis and the Y-axis, respectively. (RRt getprojectionR(R txtyR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR'&s cCsw|j|r0|j|jjd|jS|jdkrj|dkrZ|j}n|jj|S|jjS(s Returns a histogram for the image. The histogram is returned as a list of pixel counts, one for each pixel value in the source image. If the image has more than one band, the histograms for all bands are concatenated (for example, the histogram for an "RGB" image contains 768 values). A bilevel image (mode "1") is treated as a greyscale ("L") image by this method. If a mask is provided, the method returns a histogram for those parts of the image where the mask image is non-zero. The mask image must have the same size as the image, and be either a bi-level image (mode "1") or a greyscale image ("L"). :param mask: An optional mask. :returns: A list containing pixel counts. iRR(ii(RRN(RRRR=R>R!(R tmaskR"((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR2s   cCstddS(NsCoffset() has been removed. Please call ImageChops.offset() instead.(R(R txoffsettyoffset((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytoffsetOscCst|r'|d kr'|}d }n|d kr<d }nt|dkrt|rf|j}n$t|r~|j}n td||d|d|d|df7}nt|rddlm}|j||j }njt|rS|j |j |j krG|j dks/|j d krG|j |j }qGn|j }n|j |r|j |j j|||j n|j j||d S( s Pastes another image into this image. The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the left, upper, right, and lower pixel coordinate, or None (same as (0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size of the pasted image must match the size of the region. If the modes don't match, the pasted image is converted to the mode of this image (see the :py:meth:`~PIL.Image.Image.convert` method for details). Instead of an image, the source can be a integer or tuple containing pixel values. The method then fills the region with the given color. When creating RGB images, you can also use color strings as supported by the ImageColor module. If a mask is given, this method updates only the regions indicated by the mask. You can use either "1", "L" or "RGBA" images (in the latter case, the alpha band is used as mask). Where the mask is 255, the given image is copied as is. Where the mask is 0, the current value is preserved. Intermediate values will mix the two images together, including their alpha channels if they have them. See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to combine images with respect to their alpha channels. :param im: Source image or pixel value (integer or tuple). :param box: An optional 4-tuple giving the region to paste into. If a 2-tuple is used instead, it's treated as the upper left corner. If omitted or None, the source is pasted into the upper left corner. If an image is given as the second argument and there is no third, the box defaults to (0, 0), and the second argument is interpreted as a mask image. :param mask: An optional mask image. iis,cannot determine region size; use 4-item boxi(t ImageColorR R(tRGBaN(ii(R(R/(RR>RJR?R|RRRR.RR=RRRRtpaste(R RRR*R?R.((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR0Ss6(        +      cCst|ttfs$tdnt|ttfsHtdnt|d kritdnt|dkstdnt|dkrtdnt|dkrtd nt|dkr||j}n|d |jkr |}n|j|}||d|j|d |j f}|d|jkr[|}n|j|}t ||}|j ||d S(s. 'In-place' analog of Image.alpha_composite. Composites an image onto this image. :param im: image to composite over this one :param dest: Optional 2 tuple (left, top) specifying the upper left corner in this (destination) image. :param source: Optional 2 (left, top) tuple for the upper left corner in the overlay source image, or 4 tuple (left, top, right, bottom) for the bounds of the source rectangle Performance Note: Not currently implemented in-place in the core layer. sSource must be a tuplesDestination must be a tupleiisSource must be a 2 or 4-tuplesDestination must be a 2-tupleisSource must be non-negatives Destination must be non-negativeiN(ii(ii(ii( R_R%R`R|RJRR?RRRtalpha_compositeR0(R RtdesttsourcetoverlayRt backgroundtresult((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR1s. & cCs|jt|tr&|j|St|r|jdkrot|\}}|j|jj ||Sgt dD]}||^q||jj }n|jdkrt dn|j|jj||S(s Maps this image through a lookup table or function. :param lut: A lookup table, containing 256 (or 65536 if self.mode=="I" and mode == "L") values per band in the image. A function can be used instead, it should take a single argument. The function is called once for each possible pixel value, and the resulting table is applied to all bands of the image. :param mode: Output mode (default is same as input). In the current version, this can only be used if the source image has mode "L" or "P", and the output has mode "1" or the source image mode is "I" and the output mode is "L". :returns: An :py:class:`~PIL.Image.Image` object. RsI;16Ris+point operation not supported for this mode(RsI;16R( RR_tImagePointHandlertpointtcallableR=RRRtpoint_transformRRHR|(R tlutR=tscaleR-R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR8s   2cCs|j|jd kryt|jd}y|jj|WnJttfk r|jj|}|jd krtn||_nXd |_ |jj|_Wqt tfk rtdqXn|jdkrd}nd}t |rH|jd krtdn|j |jdkr|jd}qnJy|jj ||Wn,ttfk rtd|j|}nXd S|jj|j|d S( sz Adds or replaces the alpha layer in this image. If the image does not have an alpha layer, it's converted to "LA" or "RGBA". The new layer must be either "L" or "1". :param alpha: The new alpha layer. This can either be an "L" or "1" image having the same size as this image, or an integer or other color value. R9R(R'sillegal image modeiiRRN(R9R((R9R((RR(RR=RERtsetmodeReR|RR>RRbRRtfillbandRR?tputband(R talphaR=RR ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytputalphas<       g?gcCs$|j|jj|||dS(s Copies pixel data to this image. This method copies data from a sequence object into the image, starting at the upper left corner (0, 0), and continuing until either the image or the sequence ends. The scale and offset values are used to adjust the sequence values: **pixel = value*scale + offset**. :param data: A sequence object. :param scale: An optional scale value. The default is 1.0. :param offset: An optional offset value. The default is 0.0. N(RRtputdata(R RsR<R-((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRB1s R cCsddlm}|jd kr.tdn|jt||jre|j|j|j}nRt|t st rt |}qdj d|D}n|j||}d|_||_d|j_|jd S( s Attaches a palette to this image. The image must be a "P" or "L" image, and the palette sequence must contain 768 integer values, where each group of three values represent the red, green, and blue values for the corresponding pixel index. Instead of an integer sequence, you can use an 8-bit string. :param data: A palette sequence (either a list or a string). :param rawmode: The raw mode of the palette. i(RRR!sillegal image modeRRcss|]}t|VqdS(N(tchr(t.0R(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pys ZsR N(RR!( RRRR=R|RR_RRRRRR(R RsRRR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRBs     cCsO|jr|jn|j|jr<|jj||S|jj||S(s Modifies the pixel at the given position. The color is given as a single numerical value for single-band images, and a tuple for multi-band images. Note that this method is relatively slow. For more extensive changes, use :py:meth:`~PIL.Image.Image.paste` or the :py:mod:`~PIL.ImageDraw` module instead. See: * :py:meth:`~PIL.Image.Image.paste` * :py:meth:`~PIL.Image.Image.putdata` * :py:mod:`~PIL.ImageDraw` :param xy: The pixel coordinate, given as (x, y). See :ref:`coordinate-system`. :param value: The pixel value. (RRRRRR(R R&Rq((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRas     c Csddlm}|jdkr.tdn|dkr|jdkrb|jjdd }qtdtdD}n|}d }d gd }xAt |D]3\}}|||d |d d !7}|||sRRiiiRR?s(RR!N(RRRR=R|R>RRt bytearrayRt enumerateRRRRRRJ( R tdest_maptsource_paletteRtreal_source_palettet palette_bytest new_positionsRt oldPositiontmapping_palettetm_imtnew_palette_bytes((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt remap_palette~s8           cCs6|ttttttfkr-tdnt|}|d krUd |j }n t|}|j |kr|d |j kr|j S|j d krt}n|j dkr|j dj |||j dS|j dkr |j dj |||j dS|j|j|jj |||S( s Returns a resized copy of this image. :param size: The requested size in pixels, as a 2-tuple: (width, height). :param resample: An optional resampling filter. This can be one of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BOX`, :py:attr:`PIL.Image.BILINEAR`, :py:attr:`PIL.Image.HAMMING`, :py:attr:`PIL.Image.BICUBIC` or :py:attr:`PIL.Image.LANCZOS`. If omitted, or if the image has mode "1" or "P", it is set :py:attr:`PIL.Image.NEAREST`. See: :ref:`concept-filters`. :param box: An optional 4-tuple of floats giving the region of the source image which should be scaled. The values should be within (0, 0, width, height) rectangle. If omitted or None, the entire source is used. :returns: An :py:class:`~PIL.Image.Image` object. sunknown resampling filteriRR!R9tLaR(R/N(ii(ii(RR!(tNEARESTtBILINEARtBICUBICtLANCZOStBOXtHAMMINGR|R`R>R?RR=RtresizeRRR(R R?tresampleR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRXs"   "  %% cCs|d}|p|s|dkr,|jS|dkrE|jtS|dkrd|rd|jtS|dkr|r|jtSn|j\}}|dkrd} n|} |dkr|d|df} n|} tj| }t tj |dt tj |ddt tj | dt tj |ddg} d } | | d | d| d  | d | \| d <| d <| d c| d7<| d c| d 7<|rg} g}xdd|df||fd|ffD]>\}}| ||| \}}| j ||j |qWt tjt| tjt| }t tjt|tjt|}| || d|| d| \| d <| d <||}}n|j||ft| |d |S(s Returns a rotated copy of this image. This method returns a copy of this image, rotated the given number of degrees counter clockwise around its centre. :param angle: In degrees counter clockwise. :param resample: An optional resampling filter. This can be one of :py:attr:`PIL.Image.NEAREST` (use nearest neighbour), :py:attr:`PIL.Image.BILINEAR` (linear interpolation in a 2x2 environment), or :py:attr:`PIL.Image.BICUBIC` (cubic spline interpolation in a 4x4 environment). If omitted, or if the image has mode "1" or "P", it is set :py:attr:`PIL.Image.NEAREST`. See :ref:`concept-filters`. :param expand: Optional expansion flag. If true, expands the output image to make it large enough to hold the entire rotated image. If false or omitted, make the output image the same size as the input image. Note that the expand flag assumes rotation around the center and no translation. :param center: Optional center of rotation (a 2-tuple). Origin is the upper left corner. Default is the center of the image. :param translate: An optional post-rotate translation (a 2-tuple). :param fillcolor: An optional color for area outside the rotated image. :returns: An :py:class:`~PIL.Image.Image` object. gv@iiiZig@igc SsB|\}}}}}}||||||||||fS(N(( R(R)RR~RRRR\R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt transformFsiiit fillcolorN(ii(ii(Rt transposet ROTATE_180t ROTATE_90t ROTATE_270R?R>tmathtradiansRtcostsinRRtceilRtfloorRRZtAFFINE(R tangleRYRtcentert translateR[twRt post_transt rotn_centerRRZtxxtyyR(R)tnwtnh((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytrotatesN          -4 '1 .. c Ksd}t}t|r'|}t}n*trQt|trQt|}t}n| rt|drt|jr|j}n|j |j dt}||_ d |_ t tjj|dj}|s)|tkrtnyt|}Wq)tk r%tdj|q)Xn|jtkrEtn|r^t|j}nt|j}|r|jdtrtj|d}qtj|d}nz||||Wd |r|jnXd S( s Saves this image under the given filename. If no format is specified, the format to use is determined from the filename extension, if possible. Keyword options can be used to provide additional instructions to the writer. If a writer doesn't recognise an option, it is silently ignored. The available options are described in the :doc:`image format documentation <../handbook/image-file-formats>` for each writer. You can use a file object instead of a filename. In this case, you must always specify the format. The file object must implement the ``seek``, ``tell``, and ``write`` methods, and be opened in binary mode. :param fp: A filename (string), pathlib.Path object or file object. :param format: Optional format override. If omitted, the format to use is determined from the filename extension. If a file object was used instead of a filename, this parameter should always be used. :param params: Extra parameters to the image writer. :returns: None :exception ValueError: If the output format could not be determined from the file name. Use the format option to solve this. :exception IOError: If the file could not be written. The file may have been created, and may contain partial data. RRRtsave_allisunknown file extension: {}Rsr+bsw+bN((RRRt HAS_PATHLIBR_RtstrRRRtpopt encoderinfot encoderconfigRSRtpathtsplitexttlowert EXTENSIONR]RbR|RtupperRZtSAVE_ALLRtbuiltinstopenR( R RRtparamsRtopen_fpRrtextt save_handler((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRdsH    %        cCs|dkrtndS(sJ Seeks to the given frame in this sequence file. If you seek beyond the end of the sequence, the method raises an **EOFError** exception. When a sequence file is opened, the library automatically seeks to frame 0. Note that in the current version of the library, most sequence formats only allows you to seek to the next frame. See :py:meth:`~PIL.Image.Image.tell`. :param frame: Frame number, starting at 0. :exception EOFError: If the call attempts to seek beyond the end of the sequence. iN(tEOFError(R tframe((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytseeks cCst|d|d|dS(s Displays this image. This method is mainly intended for debugging purposes. On Unix platforms, this method saves the image to a temporary PPM file, and calls either the **xv** utility or the **display** utility, depending on which one can be found. On macOS, this method saves the image to a temporary BMP file, and opens it with the native Preview application. On Windows, it saves the image to a temporary BMP file, and uses the standard BMP display utility to show it (usually Paint). :param title: Optional title to use for the image window, where possible. :param command: command used to show the image ttitletcommandN(t_show(R RR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pytshowscCsS|j|jjdkr.|jg}nt|j|jj}t|S(s Split this image into individual bands. This method returns a tuple of individual image bands from an image. For example, splitting an "RGB" image creates three new images each containing a copy of one of the original bands (red, green, blue). If you need only one band, :py:meth:`~PIL.Image.Image.getchannel` method can be more convenient and faster. :returns: A tuple containing bands. i(RRRHRRRtsplitR`(R R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs  cCst|jt|r[y|jj|}Wq[tk rWtdj|q[Xn|j|jj|S(s@ Returns an image containing a single channel of the source image. :param channel: What channel to return. Could be index (0 for "R" channel of "RGB") or channel name ("A" for alpha channel of "RGBA"). :returns: An image in "L" mode. .. versionadded:: 4.3.0 sThe image has no channel "{}"( RRRtindexR|RRRR(R tchannel((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt getchannels   cCsdS(s Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`. :returns: Frame number, starting with 0. i((R ((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyttell scCs|j\}}||dkrStt||d|d}t|d}n||dkrtt||d|d}t|d}n||f}||jkrdS|jd||j||}|j|_|j|_||_d|_ d|_ dS(s= Make this image into a thumbnail. This method modifies the image to contain a thumbnail version of itself, no larger than the given size. This method calculates an appropriate thumbnail size to preserve the aspect of the image, calls the :py:meth:`~PIL.Image.Image.draft` method to configure the file reader (where applicable), and finally resizes the image. Note that this function modifies the :py:class:`~PIL.Image.Image` object in place. If you need to use the full resolution image as well, apply this method to a :py:meth:`~PIL.Image.Image.copy` of the original image. :param size: Requested size. :param resample: Optional resampling filter. This can be one of :py:attr:`PIL.Image.NEAREST`, :py:attr:`PIL.Image.BILINEAR`, :py:attr:`PIL.Image.BICUBIC`, or :py:attr:`PIL.Image.LANCZOS`. If omitted, it defaults to :py:attr:`PIL.Image.BICUBIC`. (was :py:attr:`PIL.Image.NEAREST` prior to version 2.5.0) :returns: None iiN( R?RRR R>RXRR=RRR(R R?RYR(R)R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt thumbnails"!!     ic Csk|jdkr=|jdj||||||jdS|jdkrz|jdj||||||jdSt|tr|j||d|d|St|dr|j\}}n|d krtdnt |j||}|t krAx_|D].\}} |j ||t | ||d kq Wn&|j d ||||||d k|S( s\ Transforms this image. This method creates a new image with the given size, and the same mode as the original, and copies data to the new image using the given transform. :param size: The output size. :param method: The transformation method. This is one of :py:attr:`PIL.Image.EXTENT` (cut out a rectangular subregion), :py:attr:`PIL.Image.AFFINE` (affine transform), :py:attr:`PIL.Image.PERSPECTIVE` (perspective transform), :py:attr:`PIL.Image.QUAD` (map a quadrilateral to a rectangle), or :py:attr:`PIL.Image.MESH` (map a number of source quadrilaterals in one operation). It may also be an :py:class:`~PIL.Image.ImageTransformHandler` object:: class Example(Image.ImageTransformHandler): def transform(size, method, data, resample, fill=1): # Return result It may also be an object with a :py:meth:`~method.getdata` method that returns a tuple supplying new **method** and **data** values:: class Example(object): def getdata(self): method = Image.EXTENT data = (0, 0, 100, 100) return method, data :param data: Extra data to the transformation method. :param resample: Optional resampling filter. It can be one of :py:attr:`PIL.Image.NEAREST` (use nearest neighbour), :py:attr:`PIL.Image.BILINEAR` (linear interpolation in a 2x2 environment), or :py:attr:`PIL.Image.BICUBIC` (cubic spline interpolation in a 4x4 environment). If omitted, or if the image has mode "1" or "P", it is set to :py:attr:`PIL.Image.NEAREST`. :param fill: If **method** is an :py:class:`~PIL.Image.ImageTransformHandler` object, this is one of the arguments passed to it. Otherwise, it is unused. :param fillcolor: Optional fill color for the area outside the transform in the output image. :returns: An :py:class:`~PIL.Image.Image` object. R9RQR(R/RYtfillRsmissing method dataiN(ii( R=RRZR_tImageTransformHandlerRRR>R|RtMESHt_Image__transformertQUAD( R R?RRsRYRR[RRtquad((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRZFs(,  c Cs6|d|d}|d|d}|tkr@|dd!}n|tkr|\} } } } t| | |} t| | |}t}| d| d|| f}n|tkr|dd!}n|tkr|dd!}|dd!}|dd!}|dd!}|\} } d|}d|}| |d| ||d| ||d|d|d| ||| |d| ||d| ||d|d|d| ||f}n td |tttfkrtd n|j |j |j d krt}n|j j ||j ||||dS(Niiiiiiig?sunknown transformation methodsunknown resampling filterRR!(RR!( RftEXTENTtfloatt PERSPECTIVERR|RRRSRTRR=Rt transform2(R RRRRsRYRRjRRR R R txstysRotswtsetnetAstAt((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt __transformers@           !#!,    cCs#|j|j|jj|S(s Transpose image (flip or rotate in 90 degree steps) :param method: One of :py:attr:`PIL.Image.FLIP_LEFT_RIGHT`, :py:attr:`PIL.Image.FLIP_TOP_BOTTOM`, :py:attr:`PIL.Image.ROTATE_90`, :py:attr:`PIL.Image.ROTATE_180`, :py:attr:`PIL.Image.ROTATE_270`, :py:attr:`PIL.Image.TRANSPOSE` or :py:attr:`PIL.Image.TRANSVERSE`. :returns: Returns a flipped or rotated copy of this image. (RRRR\(R R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR\s cCs#|j|j|jj|S(sj Randomly spread pixels in an image. :param distance: Distance to spread pixels. (RRRt effect_spread(R tdistance((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs cCs5ddlm}|js(tdn|j|S(s#Returns a QImage copy of this imagei(tImageQtsQt bindings are not installed(RRRtqt_is_installedR ttoqimage(R R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs cCs5ddlm}|js(tdn|j|S(s$Returns a QPixmap copy of this imagei(RsQt bindings are not installed(RRRRR t toqpixmap(R R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs N(ii(ii(TRRt__doc__R>Rtformat_descriptionRt!_close_exclusive_fp_after_loadingRttpropertyRRR?RRRRtsyst version_infotmajorRRRRRRRRRRRRRRRRRRtWEBRRRt__copy__RRR RRRRRRR!R$RRR'RR-R0R1R8RARBRRRPRRRXRqRRRRRRRTRRZRR\RRR(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRs              +     $ ,              Q0 ' 6   L0 i S     1J0  R7cBseZRS((RR(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR7sRcBseZRS((RR(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRscCstjtjdS(s+Create greyscale wedge (for debugging only)R(RRRdtwedge(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_wedgescCsxt|ttfs$tdnt|dkrEtdn|ddkse|ddkrttdntS(s Common check to enforce type and sanity check on size tuples :param size: Should be a 2 tuple of (width, height) :returns: True, or raises a ValueError sSize must be a tupleis Size must be a tuple of length 2iisWidth and height must be >= 0(R_R%R`R|RJR(R?((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt _check_size s cCst||dkr2tjtj||St|rcddlm}|j ||}ntjtj |||S(s Creates a new image with the given mode and size. :param mode: The mode to use for the new image. See: :ref:`concept-modes`. :param size: A 2-tuple, containing (width, height) in pixels. :param color: What color to use for the image. Default is black. If given, this should be a single integer or floating point value for single-band modes, and a tuple for multi-band modes (one value per band). When creating RGB images, you can also use color strings as supported by the ImageColor module. If the color is None, the image is not initialised. :returns: An :py:class:`~PIL.Image.Image` object. i(R.N( RR>RRRdRRRRR.RR(R=R?tcolorR.((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR s   RcGst|t|dkr<t|dtr<|d}n|dkr]|dkr]|}nt||}|j||||S(s Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data). You can also use any pixel decoder supported by PIL. For more information on available decoders, see the section :ref:`Writing Your Own File Decoder `. Note that this function decodes pixel data only, not entire images. If you have an entire image in a string, wrap it in a :py:class:`~io.BytesIO` object, and use :py:func:`~PIL.Image.open` to load it. :param mode: The image mode. See: :ref:`concept-modes`. :param size: The image size. :param data: A byte buffer containing raw data for the given mode. :param decoder_name: What decoder to use. :param args: Additional parameters for the given decoder. :returns: An :py:class:`~PIL.Image.Image` object. iiR((RRJR_R`RR(R=R?RsRgRhR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR1 s %  cOstdddS(Nsfromstring() has been removed. s Please call frombytes() instead.(R(RhR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRW scGst|t|dkr<t|dtr<|d}n|dkr|dkr|tjdtdd|ddf}n|dtkrt|d }|j t j |||d d|}d|_ |Snt|||||S( s Creates an image memory referencing pixel data in a byte buffer. This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data in the byte buffer, where possible. This means that changes to the original buffer object are reflected in this image). Not all modes can share memory; supported modes include "L", "RGBX", "RGBA", and "CMYK". Note that this function decodes pixel data only, not entire images. If you have an entire image file in a string, wrap it in a **BytesIO** object, and use :py:func:`~PIL.Image.open` to load it. In the current version, the default parameters used for the "raw" decoder differs from that used for :py:func:`~PIL.Image.frombytes`. This is a bug, and will probably be fixed in a future release. The current release issues a warning if you do this; to disable the warning, you should provide the full set of parameters. See below for details. :param mode: The image mode. See: :ref:`concept-modes`. :param size: The image size. :param data: A bytes or other buffer object containing raw data for the given mode. :param decoder_name: What decoder to use. :param args: Additional parameters for the given decoder. For the default encoder ("raw"), it's recommended that you provide the full set of parameters:: frombuffer(mode, size, data, "raw", mode, 0, 1) :returns: An :py:class:`~PIL.Image.Image` object. .. versionadded:: 1.1.4 iiRsthe frombuffer defaults may change in a future release; for portability, change the call to read: frombuffer(mode, size, data, 'raw', mode, 0, 1)t stacklevelii((iiN(RRJR_R`RRtRuntimeWarningt _MAPMODESRRRdt map_bufferR>RR(R=R?RsRgRhR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt frombuffer\ s # %    ! c CsP|j}|d}t|}|jdd}|dkry,d|d|df}t|\}}Wqtk rtdqXn|}|dkrd}n|d krd }nd}||krtd||fn|d|df} |dk r4t|dr%|j }q4|j }nt || |d|ddS(s Creates an image memory from an object exporting the array interface (using the buffer protocol). If **obj** is not contiguous, then the tobytes method is called and :py:func:`~PIL.Image.frombuffer` is used. If you have an image in NumPy:: from PIL import Image import numpy as np im = Image.open('hopper.jpg') a = np.asarray(im) Then this can be used to convert it to a Pillow image:: im = Image.fromarray(a) :param obj: Object with array interface :param mode: Mode to use (will be determined from type if None) See: :ref:`concept-modes`. :returns: An image object. .. versionadded:: 1.1.6 RtstridesiiRsCannot handle this data typeRRRR!RR iisToo many dimensions: %d > %d.iRRN(ii(RRRR!R( RRJRR>t_fromarray_typemapRbR{R|RRRR( tobjR=tarrRtndimRttypekeyRtndmaxR?((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt fromarray s0           cCs5ddlm}|js(tdn|j|S(s-Creates an image instance from a QImage imagei(RsQt bindings are not installed(RRRRR t fromqimage(RR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR s cCs5ddlm}|js(tdn|j|S(s.Creates an image instance from a QPixmap imagei(RsQt bindings are not installed(RRRRR t fromqpixmap(RR((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR s s1;8sI;8s|i1sF;32Fsf4sF;64Fsf8cCs|tdkrdS|d|d}|dtkrOtd|dtfn|tkrxtjd|tftndS(NiiisZImage size (%d pixels) exceeds limit of %d pixels, could be decompression bomb DOS attack.(tMAX_IMAGE_PIXELSR>RRRR(R?tpixels((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR s   trcs|dkrtd|nt}d}t|r@|}n*trjt|trjt|j}n|rtj |d}t }ny|j dWn5t t jfk rt j|j}t }nX|jd}tgfd}||||}|d kr>tr>||||}q>n|rQ||_|S|rd|jnxD]}tj|qkWtd|r|n|d S( s6 Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the :py:meth:`~PIL.Image.Image.load` method). See :py:func:`~PIL.Image.new`. See :ref:`file-handling`. :param fp: A filename (string), pathlib.Path object or a file object. The file object must implement :py:meth:`~file.read`, :py:meth:`~file.seek`, and :py:meth:`~file.tell` methods, and be opened in binary mode. :param mode: The mode. If given, this argument must be "r". :returns: An :py:class:`~PIL.Image.Image` object. :exception IOError: If the file cannot be found, or the image cannot be opened and identified. Rs bad mode %rRRtrbiic sxtD]}yt|\}}| p0||}t|ttgkr[j|n3|r|jd|||}t|j|SWqt t t t j fk rqqXqWdS(Ni(tIDRYttypeRtRRRRR?t SyntaxErrort IndexErrorR{tstructterrorR>(RRtprefixRtfactorytacceptR6R(taccept_warnings(s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt _open_core? s    scannot identify image file %rN(R|RRRsR_RRttresolveR~RRRReRtUnsupportedOperationRtreadRSR>R]RRRRRf(RR=t exclusive_fpRRRRtmessage((Rs)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR sB          cCs3|j|j|jtj|j|jS(s Alpha composite im2 over im1. :param im1: The first image. Must have mode RGBA. :param im2: The second image. Must have mode RGBA, and the same size as the first image. :returns: An :py:class:`~PIL.Image.Image` object. (RRRdR1R(tim1tim2((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR1g s  cCs6|j|j|jtj|j|j|S(s Creates a new image by interpolating between two input images, using a constant alpha.:: out = image1 * (1.0 - alpha) + image2 * alpha :param im1: The first image. :param im2: The second image. Must have the same mode and size as the first image. :param alpha: The interpolation alpha factor. If alpha is 0.0, a copy of the first image is returned. If alpha is 1.0, a copy of the second image is returned. There are no restrictions on the alpha value. If necessary, the result is clipped to fit into the allowed output range. :returns: An :py:class:`~PIL.Image.Image` object. (RRRdtblendR(RRR@((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyRv s  cCs#|j}|j|d||S(sf Create composite image by blending images using a transparency mask. :param image1: The first image. :param image2: The second image. Must have the same mode and size as the first image. :param mask: A mask image. This image can have mode "1", "L", or "RGBA", and must have the same size as the other two images. N(RR0R>(timage1timage2R*R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt composite s cGs|j|dS(s Applies the function (which should take one argument) to each pixel in the given image. If the image has more than one band, the same function is applied to each band. Note that the function is evaluated once for each possible pixel value, so you cannot use random components or other generators. :param image: The input image. :param function: A function object, taking one integer argument. :returns: An :py:class:`~PIL.Image.Image` object. i(R8(RRh((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyteval s cCst|t|ks$d|kr3tdnx[|dD]O}|jt|krhtdn|j|djkr>tdq>q>Wx|D]}|jqW|djtj |g|D]}|j ^qS(sm Merge a set of single band images into a new multiband image. :param mode: The mode to use for the output image. See: :ref:`concept-modes`. :param bands: A sequence containing one single-band image for each band in the output image. All bands must have the same size. :returns: An :py:class:`~PIL.Image.Image` object. t*swrong number of bandsis mode mismatchis size mismatch( RKRJR|R=RGR?RRRdRR(R=RHR R((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyR s $ cCs-|j}tj|||ft|RtenvironRdt set_alignmenttset_block_sizetset_blocks_maxRzRRJRR|RRR(tenvtvar_nametsettertvartunitstpostfixtmulR\((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyt_apply_env_variablest s.      (RRRRRRt_utilRtloggingRR`t getLoggerRRTRRRRtobjectR RRRRdRcR>R RRtt startswithRR~t __builtin__Rt_binaryRRRRRRRRtatexitRytcollections.abcRt collectionsRRtcffiRRRtpathlibRRstpathlib2RtNONEtFLIP_LEFT_RIGHTtFLIP_TOP_BOTTOMR^R]R_t TRANSPOSEt TRANSVERSERfRRRRRRRVRStLINEARRWRTtCUBICRUt ANTIALIAStORDEREDt RASTERIZERRRt MEDIANCUTt MAXCOVERAGEt FASTOCTREEt LIBIMAGEQUANTRtSEQUENCEt CONTAINERRtFILTEREDt HUFFMAN_ONLYtRLEtFIXEDRRYRRZR}R{RaRlt _MODEINFOt byteordert_ENDIANR<RBtsortedtMODESRRERGRIRKRQRSR]RjRoRrRpRRR7RRRRRRRRRRRRRR1RRRRRRRRRRRRRRRRRRRRtregistert clear_cache(((s)/tmp/pip-build-SKekGm/pillow/PIL/Image.pyts"                                                                #         &  = 9      U