B ¥.¦^°»ã@sŠddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z ddlmZddlmZmZmZmZmZmZddlmZmZddlmZmZejdkrÈd d „Zndd lmZesÜt ‚e !e"¡Z#Gd d „d e$ƒZ%Gdd„de&ƒZ'e(dƒZ)y:ddlm*Z+ee,e+ddƒkrFe-de,e+ddƒefƒ‚Wnpe-k r¸Z.zPee-dƒƒZ+e/e.ƒ 0d¡r†e  1de$¡n e/e.ƒ 0d¡r¦e  1e/e.ƒe$¡‚WddZ.[.XYnXe2edƒZ3y ddl4Z4Wne-k rêdZ4YnXdd„Z5dZ6dZ7dZ8dZ9dZ:dZ;dZdZ?dZ@dZAdZBdZCZ6dZDdZEZFdZGdZHZIdZJZKeDd eEd!eGd!eHd"eJd#iZLdZCZ6dZMdZNdZOdZPdZQdZRdZSdZTdZUdZVdZWdZXe2e+d$ƒrÊe+jYZYe+jZZZe+j[Z[e+j\Z\e+j]Z]gZ^iZ_iZ`iZaiZbiZciZdiZed%d&d'd(d)d*d+d,d-d.d/d0d1œ Zfejgd2krd3Zhnd4Zhd5d6d7ehd8dfehd9dfd6d:d;d;d;d:d:d:dd?d>d@dAd@dBdCdBdDœZidEdF„ZjekefƒZldGZmdHdI„ZndJdK„ZodLdM„ZpdNdO„ZqdardPdQ„ZsdRdS„Ztd¿dUdV„ZudÀdWdX„ZvdYdZ„ZwGd[d\„d\ƒZxd]d^„ZyGd_d`„d`ƒZzGdadb„dbƒZ{Gdcdd„ddƒZ|dedf„Z}dgdh„Z~dÁdidj„ZdÂdldm„Z€dndo„ZdÃdpdq„Z‚dÄdrds„Zƒdtdu„Z„dvdw„Z…dxdydzd{d|d}d~dd€dd‚dƒd„d…d†d‡dˆd‰dŠœZ†d‹e†dŒehd8f<de†dŒehd9f<dŽd„Z‡dÅd‘d’„Zˆd“d”„Z‰d•d–„ZŠd—d˜„Z‹d™dš„ZŒd›dœ„ZdÆddž„ZŽdŸd „Zd¡d¢„Zd£d¤„Z‘d¥d¦„Z’d§d¨„Z“d©dª„Z”d«d¬„Z•d­d®„Z–d¯d°„Z—dÇd±d²„Z˜d³d´„Z™dµd¶„Zšd·d¸„Z›d¹dº„ZœdÈd»d¼„Zeƒe že+jŸ¡Gd½d¾„d¾e ƒZ dS)ÉéN)ÚCallableÚMutableMapping)ÚPathé)Ú ImageModeÚTiffTagsÚUnidentifiedImageErrorÚ __version__Ú_pluginsÚ_raise_version_warning)Úi8Úi32le)Údeferred_errorÚisPath)éécCs&|dkrtƒtStd t|¡ƒ‚dS)NÚPILLOW_VERSIONz!module '{}' has no attribute '{}')r r ÚAttributeErrorÚformatÚ__name__)Úname©rú-/tmp/pip-install-mwhup7aw/Pillow/PIL/Image.pyÚ __getattr__9sr)rc@s eZdZdS)ÚDecompressionBombWarningN)rÚ __module__Ú __qualname__rrrrrKsrc@s eZdZdS)ÚDecompressionBombErrorN)rrrrrrrrOsriUUU)Ú_imagingrzjThe _imaging extension was built for another version of Pillow or PIL: Core version: %s Pillow version: %sz'The _imaging C module is not installed.zModule use of pythonz?The _imaging extension was built for another version of Python.zThe _imaging extensionÚpypy_version_infocCs t|dƒS)zÐ Checks if an object is an image object. .. warning:: This function is for internal use only. :param t: object to check if it's an image :returns: True if the object is an image Úim)Úhasattr)ÚtrrrÚ isImageType€s r#érééégà?gð?g@g@ÚDEFAULT_STRATEGY)ÚLr))Ú1)r)r))r))r)ÚI)r+)r)ÚF)r,)ÚPr))r-)ÚRGBr))ÚRÚGÚB)r.r))r/r0r1ÚX)r.r))r/r0r1ÚA)r.r))ÚCÚMÚYÚK)r.r))r6ZCbZCr)r.r))r)r3r1)r.r))ÚHÚSÚV) r*r)r+r,r-r.ÚRGBXÚRGBAÚCMYKÚYCbCrÚLABÚHSVÚlittleú<ú>)z|b1N)z|u1N)z|u1r$Úi4Zf4)z|u1r)z|u1r%)zu2N)zi2N)zu4N)zi4N)r*r)ÚLAr+r,r-r.r;r<r=r>r?r@zI;16zI;16BzI;16LzI;16SzI;16BSzI;16LSzI;32zI;32BzI;32LzI;32SzI;32BSzI;32LScCsLt|j\}}|dkr.|jd|jdf|fS|jd|jd|f|fSdS)Nrr)Ú _MODE_CONVÚmodeÚsize)r ÚtypÚextrarrrÚ_conv_type_shapesrK)r)r-r;r<r=zI;16zI;16LzI;16BcCs t |¡jS)a% 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. )rÚgetmodeZbasemode)rGrrrÚ getmodebase!s rMcCs t |¡jS)a  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. )rrLZbasetype)rGrrrÚ getmodetype.s rNcCs t |¡jS)a× 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. )rrLÚbands)rGrrrÚgetmodebandnames:s rPcCstt |¡jƒS)zÎ 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. )ÚlenrrLrO)rGrrrÚ getmodebandsIsrRcCsútdkr dSyddlm}|s"t‚Wntk r8YnXyddlm}|sPt‚Wntk rfYnXyddlm}|s~t‚Wntk r”YnXyddlm}|s¬t‚Wntk rÂYnXyddlm}|sÚt‚Wntk rðYnXdadS)z-Explicitly load standard file format drivers.rN)ÚBmpImagePlugin)ÚGifImagePlugin)ÚJpegImagePlugin)ÚPpmImagePlugin)ÚPngImagePlugin) Ú _initializedÚrSÚAssertionErrorÚ ImportErrorrTrUrVrW)rSrTrUrVrWrrrÚpreinitZs8          r\c Cs†tdkr dSxdtD]\}y&t d|¡td|tƒtƒgƒWqtk rl}zt d||¡Wdd}~XYqXqWtszt r‚dadSdS)zw Explicitly initializes the Python Imaging Library. This function loads all available file format drivers. r$rz Importing %szPIL.%szImage: failed to import %s: %sNr) rXr ÚloggerÚdebugÚ __import__ÚglobalsÚlocalsr[ÚOPENÚSAVE)ZpluginÚerrrÚinitˆs  $rercCs˜|dkrd}nt|tƒs|f}y t|}Wntk r>YnX||f||žŽSytt|dƒ}Wn tk r„td|ƒ‚YnX||f||žŽS)NrÚ_decoderzdecoder %s not available)Ú isinstanceÚtupleÚDECODERSÚKeyErrorÚgetattrÚcorerÚOSError)rGÚ decoder_nameÚargsrJÚdecoderrrrÚ _getdecoder¢s  rqcCs˜|dkrd}nt|tƒs|f}y t|}Wntk r>YnX||f||žŽSytt|dƒ}Wn tk r„td|ƒ‚YnX||f||žŽS)NrÚ_encoderzencoder %s not available)rgrhÚENCODERSrjrkrlrrm)rGÚ encoder_namerorJÚencoderrrrÚ _getencoder¹s  rvcCst|tƒr|St|ƒS)N)rgÚ_E)ÚvaluerrrÚcoerce_eÔsryc@s$eZdZdd„Zdd„Zdd„ZdS)rwcCs ||_dS)N)Údata)ÚselfrzrrrÚ__init__Ùsz _E.__init__cCst|jdt|ƒjfƒS)NÚ__add__)rwrzry)r{Úotherrrrr}Üsz _E.__add__cCst|jdt|ƒjfƒS)NÚ__mul__)rwrzry)r{r~rrrrßsz _E.__mul__N)rrrr|r}rrrrrrwØsrwcCsîdg}|t|ƒƒj}yV|\}}}||krD|dkrDt|tjƒrD|dfS||krh|dkrht|tjƒrhd|fSWntk r~YnXyL|\\}}}}}||krÊ|dkrÊt|tjƒrÊ|dkrÊt|tjƒrÊ||fSWntk ràYnXtdƒ‚dS)NÚstubrgr}gð?zillegal expression)rwrzrgÚnumbersÚNumberÚ TypeErrorÚ ValueError)Úexprr€rzÚaÚbÚcÚdrdrrrÚ_getscaleoffsetãs*     rŠc@sÀeZdZdZdZdZdZdd„Zedd„ƒZ edd „ƒZ ed d „ƒZ d d „Z dd„Z dd„Zdd„Zdd„Zdd„Zdšdd„Zdd„Zdd„Zdd„Zed d!„ƒZd"d#„Zd$d%„Zd›d'd(„Zd)d*„Zdœd,d-„Zdd.d/„Zd0d1„Zd2d3„Zd4d5„Zddde d6fd7d8„Z!džd;d<„Z"d=d>„Z#e#Z$dŸd?d@„Z%dAdB„Z&dCdD„Z'd dEdF„Z(dGdH„Z)dIdJ„Z*dKdL„Z+d¡dMdN„Z,d¢dOdP„Z-dQdR„Z.dSdT„Z/dUdV„Z0dWdX„Z1dYdZ„Z2d[d\„Z3d£d]d^„Z4d¤d_d`„Z5d¥dadb„Z6d¦dcdd„Z7d§dfdg„Z8d¨dhdi„Z9djdk„Z:d©dndo„Z;dªdqdr„Zdwdx„Z?e@ddfdydz„ZAd¬d{d|„ZBeCd9dddfd}d~„ZDd­dd€„ZEdd‚„ZFd®dƒd„„ZGd…d†„ZHd‡dˆ„ZId‰dŠ„ZJe@d‹fdŒd„ZKdeCd:dfdŽd„ZLeCd:fdd‘„ZMd’d“„ZNd”d•„ZOd–d—„ZPd˜d™„ZQdS)¯ÚImageaD 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` NTcCs:d|_d|_d|_d|_i|_t|_d|_d|_d|_ dS)NrY)rrr) r rGÚ_sizeÚpaletteÚinfoÚNORMALÚcategoryÚreadonlyÚpyaccessÚ_exif)r{rrrr|szImage.__init__cCs |jdS)Nr)rH)r{rrrÚwidthsz Image.widthcCs |jdS)Nr)rH)r{rrrÚheight"sz Image.heightcCs|jS)N)rŒ)r{rrrrH&sz Image.sizecCs`tƒ}||_|j|_|j|_|jdkrP|jr:|j ¡|_nddlm}| ¡|_|j  ¡|_ |S)N)r-ÚPAr)Ú ImagePalette) r‹r rGrHrŒrÚcopyrYr—rŽ)r{r Únewr—rrrÚ_new*s    z Image._newcCs|S)Nr)r{rrrÚ __enter__:szImage.__enter__cGsBt|dƒr8t|ddƒr8t|dƒr(| ¡|jr8|j ¡d|_dS)NÚfpÚ _exclusive_fpFÚ _close__fp)r!rkržrœÚclose)r{rorrrÚ__exit__=s   zImage.__exit__c Cszy&t|dƒr| ¡|j ¡d|_Wn.tk rT}zt d|¡Wdd}~XYnXt|ddƒrhd|_t t dƒƒ|_ dS)a’ 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. ržNzError closing: %sÚmapzOperation on closed image) r!ržrœrŸÚ Exceptionr]r^rkr¡rr„r )r{ÚmsgrrrrŸEs     z Image.closecCs$| ¡|j ¡|_d|_d|_dS)Nr)Úloadr r˜r’r‘)r{rrrÚ_copyas z Image._copycCs|jr| ¡n| ¡dS)N)r‘r¥r¤)r{rrrÚ_ensure_mutablegs zImage._ensure_mutablecKszd}|rd|}|s.t |¡\}}t |¡n|}| |¡sD||}| ¡|rX|dkrf|j |¡n|j||f|Ž|S)NrYÚ.ZPPM) ÚtempfileÚmkstempÚosrŸÚendswithr¤r Zsave_ppmÚsave)r{ÚfilerÚoptionsÚsuffixÚfÚfilenamerrrÚ_dumpms   z Image._dumpcCsh|j|jkof|j|jkof|j|jkof|j|jkof|j|jkof|j|jkof| ¡| ¡kof| ¡| ¡kS)N)Ú __class__rGrHrŽrr‘Ú getpaletteÚtobytes)r{r~rrrÚ__eq__ƒs      z Image.__eq__cCs.d|jj|jj|j|jd|jdt|ƒfS)Nz(<%s.%s image mode=%s size=%dx%d at 0x%X>rr)r³rrrGrHÚid)r{rrrÚ__repr__szImage.__repr__cCst ¡}| |d¡| ¡S)z[ iPython display hook support :returns: png version of the image as bytes ZPNG)ÚioÚBytesIOr¬Úgetvalue)r{r‡rrrÚ _repr_png_™s zImage._repr_png_cCsTi}t|ƒ\}}||d<||d<d|d<|jdkrD| dd¡|d<n | ¡|d<|S) NÚshapeÚtypestrrÚversionr*Úrawr)rz)rKrGrµ)r{r™r½r¾rrrÚ__array_interface__¢s   zImage.__array_interface__cCs|j|j|j| ¡| ¡gS)N)rŽrGrHr´rµ)r{rrrÚ __getstate__²szImage.__getstate__cCsbt |¡g|_|\}}}}}||_||_||_t ||¡|_|dkrT|rT|  |¡|  |¡dS)N)r)rEr-r–) r‹r|ZtilerŽrGrŒrlr™r Ú putpaletteÚ frombytes)r{ÚstaterŽrGrHrrzrrrÚ __setstate__µs   zImage.__setstate__rÀc Gs¶t|ƒdkr"t|dtƒr"|d}|dkr8|dkr8|j}| ¡t|j||ƒ}| |j¡td|j ddƒ}g}x$|  |¡\}}}|  |¡|rtPqtW|dkr¬t d|ƒ‚d  |¡S) aÿ Return image as a bytes object. .. warning:: This method returns the raw image data from the internal storage. For compressed image data (e.g. PNG, JPEG) use :meth:`~.save`, with a BytesIO parameter for in-memory data. :param encoder_name: What encoder to use. The default is to use the standard "raw" encoder. :param args: Extra arguments to the encoder. :rtype: A bytes object. rrrÀrir%zencoder error %d in tobytesó)rQrgrhrGr¤rvÚsetimager ÚmaxrHÚencodeÚappendÚ RuntimeErrorÚjoin) r{rtrordÚbufsizerzÚlÚsr‰rrrrµÁs"   z Image.tobytescOs tdƒ‚dS)Nz;tostring() has been removed. Please call tobytes() instead.)ÚNotImplementedError)r{roÚkwrrrÚtostringìszImage.tostringÚimagecCsj| ¡|jdkrtdƒ‚| d¡}d d||jdf d¡d||jd f d¡d | d¡|d g¡S) a- Returns the image converted to an X11 bitmap. .. note:: This method only works for mode "1" images. :param name: The name prefix to use for the bitmap variables. :returns: A string containing an X11 bitmap. :raises ValueError: If the mode is not "1" r*z not a bitmapZxbmrÇz#define %s_width %d rÚasciiz#define %s_height %d rzstatic char %s_bits[] = { s};)r¤rGr„rµrÍrHrÊ)r{rrzrrrÚtobitmapñs    zImage.tobitmapcGsˆt|ƒdkr"t|dtƒr"|d}|dkr8|dkr8|j}t|j||ƒ}| |j¡| |¡}|ddkrptdƒ‚|ddkr„tdƒ‚dS)zç Loads this image with pixel data from a bytes object. This method is similar to the :py:func:`~PIL.Image.frombytes` function, but loads data into this image instead of creating a new image object. rrrÀrznot enough image datazcannot decode image dataN) rQrgrhrGrqrÈr Údecoder„)r{rzrnror‰rÐrrrrÄ s     zImage.frombytescOs tdƒ‚dS)Nz?fromstring() has been removed. Please call frombytes() instead.)rÑ)r{rorÒrrrÚ fromstring$szImage.fromstringcCsÜ|jrˆ|jrˆ|jjrˆ|jj|j ¡Žd|j_d|j_d|j_d|jkrˆt|jdt ƒrn|j  |jdd¡n|j  |jd¡d|j_|jrØt rÊt rÊ|jr¢|jSddlm}| ||j¡|_|jrÊ|jS|j |j¡SdS)aŠ Allocates storage for the image and loads the pixel data. In normal cases, you don't need to call this method, since the Image class automatically loads an opened image when it is accessed for the first time. If the file associated with the image was opened by Pillow, then this method will close it. The exception to this is if the image has multiple frames, in which case the file will be left open for seek operations. See :ref:`file-handling` for more information. :returns: An image access object. :rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess` rr.NÚ transparencyr<r)ÚPyAccess)r rZdirtyrÃÚgetdatarGÚrawmoderŽrgÚintÚputpalettealphaÚputpalettealphasÚcffiÚUSE_CFFI_ACCESSr’rYrÚr™r‘Z pixel_access)r{rÚrrrr¤)s&  z Image.loadcCsdS)as 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. Nr)r{rrrÚverifyPs z Image.verifyéc s>| ¡|s*|jdkr*|jr&|jj}nd}|r<||jkrDˆsD| ¡S|j d¡dk }ˆrô|dkrhtdƒ‚|j |ˆ¡}|  |¡}|rð|jj dkrð|jd‰dd „‰|d kr¶ˆˆˆƒ‰n0t |ƒdkræt ‡‡‡fd d „t d t ˆƒƒDƒƒ‰ˆ|jd<|S|dkr|jdkr| |¡Sd} d} |rž|jdkr^|dkr^|  |j ||jd¡¡} | jd=| S|jdkr<|dkr<|jd} t| tƒršt d¡d} n tƒ  t |jd¡¡} |jdkr|  |j¡t| t ƒry| j | ¡} Wntk rtdƒ‚YnX|  d| ¡|dkr&|  |¡} n |  d¡} |  d¡} nb|jdkrž|dkrž|jd} d} t| tƒrz|j | ¡n$t| tƒr–|j | d ¡ntdƒ‚|dkrF|t krF|j |¡}|  |¡}ddl!m"}| #d|j $d¡¡|_| rø|jd=| dk rBy|j | ¡|jd<Wn(tk r@|jd=t d¡YnX|S|dkrTt%}y|j ||¡}WnXtk r¾y"|j t&|jƒ¡}| ||¡}Wnt'k r¸tdƒ‚YnXYnX|  |¡} | rØ| jd=| dk r:| jdkr0y| j | ¡| jd<Wn(tk r,| jd=t d¡YnXn | | jd<| S)aò Returns a converted copy of this image. For the "P" mode, this method translates pixels through the palette. If mode is omitted, a mode is chosen so that all information in the image and the palette can be represented without a palette. The current version supports all possible conversions between "L", "RGB" and "CMYK." The **matrix** argument only supports "L" and "RGB". When translating a color image to greyscale (mode "L"), the library uses the ITU-R 601-2 luma transform:: L = R * 299/1000 + G * 587/1000 + B * 114/1000 The default method of converting a greyscale ("L") or "RGB" image into a bilevel (mode "1") image uses Floyd-Steinberg dither to approximate the original image luminosity levels. If dither is NONE, all values larger than 128 are set to 255 (white), all other values to 0 (black). To use other thresholds, use the :py:meth:`~PIL.Image.Image.point` method. When converting from "RGBA" to "P" without a **matrix** argument, this passes the operation to :py:meth:`~PIL.Image.Image.quantize`, and **dither** and **palette** are ignored. :param mode: The requested mode. See: :ref:`concept-modes`. :param matrix: An optional conversion matrix. If given, this should be 4- or 12-tuple containing floating point values. :param dither: Dithering method, used when converting from mode "RGB" to "P" or from "RGB" or "L" to "1". Available methods are NONE or FLOYDSTEINBERG (default). Note that this is not used when **matrix** is supplied. :param palette: Palette to use when converting from mode "RGB" to "P". Available palettes are WEB or ADAPTIVE. :param colors: Number of colors to use for the ADAPTIVE palette. Defaults to 256. :rtype: :py:class:`~PIL.Image.Image` :returns: An :py:class:`~PIL.Image.Image` object. r-r.rÙN)r)r.zillegal conversionrcSsP|d|d|d|d|d|d|dd}tdtdt|ƒƒƒS)Nrrr$rgà?éÿ)rÉÚminrÝ)ÚmÚvrrrÚconvert_transparencyšs<z+Image.convert..convert_transparencyr)cs*g|]"}ˆˆ|d|dd…ˆƒ‘qS)r%r)Ú.0Úi)rèÚmatrixrÙrrú £sz!Image.convert..rr<F)r*r)r+r.)r)r.r-zVPalette images with Transparency expressed in bytes should be converted to RGBA imagesT)rrz2Couldn't allocate a palette color for transparency)rrz.Transparency for P mode should be bytes or intr)r—z0Couldn't allocate palette entry for transparency)(r¤rGrr˜rŽÚgetr„r Zconvert_matrixršrOrQrhÚrangeÚquantizeZconvert_transparentrgÚbytesÚwarningsÚwarnr‹rlr™rÃÚgetcolorr¢ÚputpixelÚconvertÚgetpixelrßrÝrÞÚADAPTIVErYr—rÀr´ÚFLOYDSTEINBERGrMrj)r{rGrëÚditherrÚcolorsZhas_transparencyr r™ZtrnsZ delete_trnsZnew_imr"Ztrns_imr—r)rèrërÙrrõ[sÄ*                              z Image.convertrrc CsÚ| ¡|dkr"d}|jdkr"d}|jdkr<|dkrfilter argument should be ImageFilter.Filter instance or class)rYr r¤rgrr!rƒZMultibandFilterr rOršr rîrËÚgetbandÚmergerG)r{r r Z multibandÚimsrˆrrrr  s    "z Image.filtercCst |j¡jS)zä 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 )rrLrGrO)r{rrrÚgetbands¼szImage.getbandscCs| ¡|j ¡S)aQ 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. )r¤r Úgetbbox)r{rrrrÆs z Image.getbboxcCsl| ¡|jdkr`|j ¡}g}x*tdƒD]}||r*| |||f¡q*Wt|ƒ|kr\dS|S|j |¡S)a 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. )r*r)r-rãN)r¤rGr Ú histogramrîrËrQÚ getcolors)r{Z maxcolorsÚhÚoutrêrrrrÕs    zImage.getcolorscCs"| ¡|dk r|j |¡S|jS)aå 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)r¤r r )r{ÚbandrrrrÛës z Image.getdatacCsV| ¡|jjdkrLg}x*t|jjƒD]}| |j |¡ ¡¡q&Wt|ƒS|j ¡S)a& 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. r)r¤r rOrîrËr Ú getextremarh)r{Úextremarêrrrrs  zImage.getextremacCs,|jdkrtƒ|_|j |j d¡¡|jS)NZexif)r“ÚExifr¤rŽrí)r{rrrÚgetexifs z Image.getexifcCs| ¡|jjS)zr Returns a capsule that points to the internal image memory. :returns: A capsule object. )r¤r Úptr)r{rrrÚgetimsz Image.getimcCs0| ¡yt|j ¡ƒStk r*dSXdS)z  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)r¤Úlistr r´r„)r{rrrr´$s zImage.getpalettecCs&| ¡|jr|j |¡S|j |¡S)a  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. )r¤r’rör )r{Úxyrrrrö2s  zImage.getpixelcCs2| ¡|j ¡\}}dd„|Dƒdd„|DƒfS)z¸ 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. cSsg|] }t|ƒ‘qSr)r )rérˆrrrrìKsz'Image.getprojection..)r¤r Ú getprojection)r{ÚxÚyrrrrAszImage.getprojectioncCsT| ¡|r$| ¡|j d|j¡S|jdkrJ|dkr>| ¡}|j |¡S|j ¡S)ae 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. :param extrema: An optional tuple of manually-specified extrema. :returns: A list containing pixel counts. )rr)r+r,N)r¤r rrGr)r{ÚmaskrrrrrMs  zImage.histogramcCsT| ¡|r$| ¡|j d|j¡S|jdkrJ|dkr>| ¡}|j |¡S|j ¡S)ah Calculates and returns the entropy for the image. A bilevel image (mode "1") is treated as a greyscale ("L") image by this method. If a mask is provided, the method employs the 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. :param extrema: An optional tuple of manually-specified extrema. :returns: A float value representing the image entropy )rr)r+r,N)r¤r ÚentropyrGr)r{r rrrrr!ks  z Image.entropycCs tdƒ‚dS)NzCoffset() has been removed. Please call ImageChops.offset() instead.)rÑ)r{ZxoffsetZyoffsetrrrÚoffset…sz Image.offsetcCs t|ƒr|dkr|}d}|dkr$d}t|ƒdkr|t|ƒr@|j}nt|ƒrP|j}ntdƒ‚||d|d|d|df7}t|tƒr¢ddlm}| ||j ¡}nBt|ƒrä|  ¡|j |j krÞ|j dksÒ|j d krÞ|  |j ¡}|j }|  ¡|r|  ¡|j  |||j ¡n|j  ||¡dS) a’ 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. N)rrr$z,cannot determine region size; use 4-item boxrr)Ú ImageColorr.)r<ÚRGBa)r#rQrHr„rgÚstrrYr#rórGr¤rõr r¦Úpaste)r{r rýr rHr#rrrr&Šs4( $    z Image.paste©rrcCst|ttfƒstdƒ‚t|ttfƒs,tdƒ‚t|ƒdkr@tdƒ‚t|ƒdksTtdƒ‚t|ƒdkrhtdƒ‚t|ƒdkr|td ƒ‚t|ƒdkr’||j}|d |jkr¦|}n | |¡}||d|j|d |j f}|d |jkrä|}n | |¡}t ||ƒ}|  ||¡d S) a. '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. zSource must be a tuplezDestination must be a tuple)r$r%zSource must be a 2 or 4-tupler$zDestination must be a 2-tuplerzSource must be non-negativez Destination must be non-negative)rrrN) rgrrhr„rQrårHrþr”r•Úalpha_compositer&)r{r ÚdestÚsourceÚoverlayrýZ backgroundÚresultrrrr(Ús.          zImage.alpha_compositecs’| ¡tˆtƒrˆ |¡Stˆƒrl|jdkrNtˆƒ\}}| |j  ||¡¡S‡fdd„t dƒDƒ|jj ‰|jdkr~t dƒ‚| |j ˆ|¡¡S)aÿ 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. )r+zI;16r,csg|] }ˆ|ƒ‘qSrr)rérê)Úlutrrrì)szImage.point..rãr,z+point operation not supported for this mode) r¤rgÚImagePointHandlerÚpointÚcallablerGrŠršr Zpoint_transformrîrOr„)r{r-rGÚscaler"r)r-rr/ s     z Image.pointc Cs@| ¡|jdkr ylt|jƒd}y|j |¡Wn8ttfk rj|j |¡}|jdkr`t‚||_YnXd|_|jj|_Wn t tfk ržtdƒ‚YnX|jdkr°d}nd}t |ƒrì|jdkrÎtdƒ‚|  ¡|jd krê| d ¡}n@y|j  ||¡Wn(ttfk r&t d |j|ƒ}YnXdS|j |j|¡dS) az 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. )rEr–r<r3Nzillegal image mode)rEr–rr)r*r)r*r))r¦rGrMr Zsetmoderr„rõr’rjr#r¤Zfillbandr™rHZputband)r{ÚalpharGr rrrrÚputalpha1s<         zImage.putalphaçð?çcCs| ¡|j |||¡dS)a 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)r¦r Úputdata)r{rzr1r"rrrr6gs z Image.putdatar.cCsddlm}|jdkrtdƒ‚| ¡t||jƒrD| |j|j¡}nt|t ƒsVt |ƒ}| ||¡}d|jkrpdnd|_||_d|j_| ¡d S) aî Attaches a palette to this image. The image must be a "P", "PA", "L" or "LA" 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. r)r—)r)rEr-r–zillegal image moder3r–r-r.N) rYr—rGr„r¤rgrÀrÜrrð)r{rzrÜr—rrrrrÃxs     zImage.putpalettecCsh|jr| ¡| ¡|jr*|j ||¡S|jdkrZt|ttfƒrZt |ƒdkrZ|j   |¡}|j  ||¡S)aÎ 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. In addition to this, RGB and RGBA tuples are accepted for P 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. r-)rr%) r‘r¥r¤r’rôrGrgrrhrQrrór )r{rrxrrrrô”s   zImage.putpixelc Cs*ddlm}|jdkrtdƒ‚|dkr^|jdkrF|j d¡dd…}qbtd d „tdƒDƒƒ}n|}d }d gd }x8t|ƒD],\}}|||d|dd…7}|||<qzWt|ƒ} |  ¡} d| _|jd| ddd| _ | jj | j   ¡Ž|   d¡} |dt|ƒd} |   | ¡|jd|t|ƒd| _ | S)a] Rewrites the image to reorder the palette. :param dest_map: A list of indexes into the original palette. e.g. [1,0] would swap a two item palette, and list(range(256)) is the identity transform. :param source_palette: Bytes or None. :returns: An :py:class:`~PIL.Image.Image` object. r)r—)r)r-zillegal image modeNr-r.icss|]}|dVqdS)rNr)rérêrrrú Îsz&Image.remap_palette..rÇrrãr)rrHr)ó)rYr—rGr„r r´Ú bytearrayrîÚ enumerater˜rrÃrÛrõrQ) r{Zdest_mapZsource_paletter—Zreal_source_paletteZ palette_bytesZ new_positionsrêÚ oldPositionZmapping_paletteZm_imZnew_palette_bytesrrrÚ remap_paletteºs2       zImage.remap_palettec Cs°t|d}|d|d|d}|d|d|d}||}||}tdt|d|ƒƒtdt|d|ƒƒt|jdt |d|¡ƒt|jdt |d|¡ƒfS)z€Expands the box so it includes adjacent pixels that may be used by resampling with the given resampling filter. gà?r$rrr)Ú_filters_supportrÉrÝrårHÚmathÚceil) r{rHÚresamplerýZfilter_supportZscale_xZscale_yZ support_xZ support_yrrrÚ _get_safe_boxs zImage._get_safe_boxc CsB|ttttttfkrzd |¡}dd„tdftdftdftdftdftd ffDƒ}t|d d  |d d …¡d|d ƒ‚|d k r’|dkr’tdƒ‚t |ƒ}|d kr®d|j }nt |ƒ}|j |krÖ|d|j krÖ|  ¡S|j dkrät}|j dkr"|  |j d d …d¡}| |||¡}|  |j ¡S| ¡|d k r,|tkr,t|d|d|d|ƒpbd}t|d|d|d|ƒpˆd} |dksž| dkr,| |||¡} || f} t|jƒrÐ|j| | d}ntj|| | d}|d| d||d| d| |d| d||d| d| f}| |j |||¡¡S)a° 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`. Default filter is :py:attr:`PIL.Image.BICUBIC`. If the image has mode "1" or "P", it is always set to :py:attr:`PIL.Image.NEAREST`. See: :ref:`concept-filters`. :param box: An optional 4-tuple of floats providing the source image region to be scaled. The values must be within (0, 0, width, height) rectangle. If omitted or None, the entire source is used. :param reducing_gap: Apply optimization by resizing the image in two steps. First, reducing the image by integer times using :py:meth:`~PIL.Image.Image.reduce`. Second, resizing using regular resampling. The last step changes size no less than by ``reducing_gap`` times. ``reducing_gap`` may be None (no first step is performed) or should be greater than 1.0. The bigger ``reducing_gap``, the closer the result to the fair resampling. The smaller ``reducing_gap``, the faster resizing. With ``reducing_gap`` greater or equal to 3.0, the result is indistinguishable from fair resampling in most cases. The default value is None (no optimization). :returns: An :py:class:`~PIL.Image.Image` object. zUnknown resampling filter ({}).cSs g|]}d |d|d¡‘qS)z{} ({})rr)r)rér rrrrì;sz Image.resize..z Image.NEARESTz Image.LANCZOSzImage.BILINEARz Image.BICUBICz Image.BOXz Image.HAMMINGz Use z, Néÿÿÿÿz or gð?z#reducing_gap must be 1.0 or greater)rr)r*r-)rEr<r†r$rrr)rý)ÚNEARESTÚBILINEARÚBICUBICÚLANCZOSÚBOXÚHAMMINGrr„rÍrhrHr˜rGrõÚresizer¤rÝrAr0Úreducer‹ršr ) r{rHr@rýÚ reducing_gapÚmessageÚfiltersr Zfactor_xZfactor_yZ reduce_boxÚfactorrrrrIsP! (    && z Image.resizecCs¦t|ttfƒs||f}|dkr*d|j}nt|ƒ}|dkrP|d|jkrP| ¡S|jdkrŠ| |jdd…d¡}| ||¡}| |j¡S| ¡|  |j  ||¡¡S)a Returns a copy of the image reduced by `factor` times. If the size of the image is not dividable by the `factor`, the resulting size will be rounded up. :param factor: A greater than 0 integer or tuple of two integers for width and height separately. :param box: An optional 4-tuple of ints providing the source image region to be reduced. The values must be within (0, 0, width, height) rectangle. If omitted or None, the entire source is used. N)rr)rr)rEr<rBr†) rgrrhrHr˜rGrõrJr¤ršr )r{rNrýr rrrrJss     z Image.reducecCs*|d}|s^|s^|dkr | ¡S|dkr2| t¡S|dkrH|rH| t¡S|dkr^|r^| t¡S|j\}}|dkrvd} n|} |dkr”|d|df} n|} t |¡ }tt  |¡d ƒtt  |¡d ƒd tt  |¡ d ƒtt  |¡d ƒd g} d d „} | | d | d| d  | d | ƒ\| d<| d<| d| d7<| d| d 7<|rg} g}xJd|df||fd|ffD].\}}| ||| ƒ\}}|   |¡|  |¡qrWt  t | ƒ¡t t| ƒ¡}t  t |ƒ¡t t|ƒ¡}| || d|| d| ƒ\| d<| d<||}}|j||ft| ||dS)a‰ 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 to :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. g€v@ré´éZiN)rrg@égc Ss8|\}}}}}}||||||||||fS)Nr) rrrër†r‡rˆr‰rdr°rrrÚ transformìszImage.rotate..transformrr$r&)Ú fillcolor)r˜Ú transposeÚ ROTATE_180Ú ROTATE_90Ú ROTATE_270rHr>ÚradiansrÿÚcosÚsinrËr?rÉÚfloorrårRÚAFFINE)r{Zangler@rÚcenterÚ translaterSÚwrZ post_transZ rotn_centerrërRZxxÚyyrrÚnwZnhrrrÚrotate”sR"       2" , z Image.rotatec KsNd}d}t|ƒr|}d}nt|tƒr0t|ƒ}d}|sNt|dƒrNt|jƒrN|j}| ¡| dd¡}||_d|_ t ƒt j   |¡d ¡}|sÊ|tkrštƒy t|}Wn"tk rÈtd |¡ƒ‚YnX| ¡tkrÜtƒ|rît| ¡}n t| ¡}|r(| d d¡rt |d ¡}n t |d ¡}z||||ƒWd |rH| ¡Xd S) a† 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. rYFTrÚsave_allrrzunknown file extension: {}rËzr+bzw+bN)rrgrr%r!rr¦ÚpopZ encoderinfoZ encoderconfigr\rªÚpathÚsplitextÚlowerÚ EXTENSIONrerjr„rÚupperrcÚSAVE_ALLríÚbuiltinsÚopenrŸ) r{rœrÚparamsr±Zopen_fprcÚextZ save_handlerrrrr¬ sH      z Image.savecCs|dkr t‚dS)aÇ 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. 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. rN)ÚEOFError)r{ÚframerrrÚseek\sz Image.seekcCst|||ddS)a… Displays this image. This method is mainly intended for debugging purposes. The image is first saved to a temporary file. By default, it will be in PNG format. On Unix, the image is then opened using the **display**, **eog** or **xv** utility, depending on which one can be found. On macOS, the image is opened with the native Preview application. On Windows, the image is opened with the standard PNG display utility. :param title: Optional title to use for the image window, where possible. :param command: command used to show the image )ÚtitleÚcommandN)Ú_show)r{rrrsrrrÚshownsz Image.showcCs:| ¡|jjdkr | ¡g}nt|j|j ¡ƒ}t|ƒS)aÏ 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. r)r¤r rOr˜r¡ršÚsplitrh)r{r rrrrv„s   z Image.splitcCsZ| ¡t|tƒrHy| ¡ |¡}Wn"tk rFtd |¡ƒ‚YnX| |j  |¡¡S)a@ 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 zThe image has no channel "{}") r¤rgr%rÚindexr„rršr r )r{ZchannelrrrÚ getchannel™s  zImage.getchannelcCsdS)z‹ Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`. :returns: Frame number, starting with 0. rr)r{rrrÚtell®sz Image.tellg@csttj|ƒ\‰‰ˆ|jkr(ˆ|jkr(dSdd„}|j|j‰ˆˆˆkrd|ˆˆ‡‡fdd„d‰n|ˆˆ‡‡fdd„d‰ˆˆf}d}|dk rÂ| d|d||d |f¡}|dk rÂ|d }|j|krö|j||||d }|j|_||_ |jj |_ d|_ d|_ dS) aÄ 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). :param reducing_gap: Apply optimization by resizing the image in two steps. First, reducing the image by integer times using :py:meth:`~PIL.Image.Image.reduce` or :py:meth:`~PIL.Image.Image.draft` for JPEG images. Second, resizing using regular resampling. The last step changes size no less than by ``reducing_gap`` times. ``reducing_gap`` may be None (no first step is performed) or should be greater than 1.0. The bigger ``reducing_gap``, the closer the result to the fair resampling. The smaller ``reducing_gap``, the faster resizing. With ``reducing_gap`` greater or equal to 3.0, the result is indistinguishable from fair resampling in most cases. The default value is 2.0 (very close to fair resampling while still being faster in many cases). :returns: None NcSs ttt |¡t |¡|ddƒS)N)Úkeyr)rÉrår>r[r?)ÚnumberrzrrrÚ round_aspectßsz%Image.thumbnail..round_aspectcstˆ|ˆƒS)N)r)Ún)ÚaspectrrrÚårÇz!Image.thumbnail..)rzcstˆˆ|ƒS)N)r)r})r~rrrrçrÇrr)rýrK) r¡r>r[r”r•rrHrIr rŒrGr‘r’)r{rHr@rKr|rýÚresr r)r~rrrÚ thumbnail¶s*%     zImage.thumbnailc Cs|jdkr*| d¡ ||||||¡ d¡S|jdkrT| d¡ ||||||¡ d¡St|tƒrp|j||||dSt|dƒr†| ¡\}}|dkr–tdƒ‚t|j||ƒ}|j   ¡|_ |t kräxF|D] \}} |  ||t | ||dk¡q¾Wn|  d ||||||dk¡|S) a^ 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. rEZLar<r$)r@ÚfillrÛNzmissing method data)rr)rGrõrRrgÚImageTransformHandlerr!rÛr„r™rŽr˜ÚMESHÚ_Image__transformerÚQUAD) r{rHrûrzr@r‚rSr rýZquadrrrrRüs,/        zImage.transformc Cs@|d|d}|d|d}|tkr8|dd…}n8|tkrz|\} } } } | | |} | | |}t}| d| d|| f}nö|tkr|dd…}nà|tkrh|dd…}|dd…}|dd…}|dd…}|\} } d|}d|}| |d| ||d| ||d|d|d| ||| |d| ||d| ||d|d|d| ||f}ntd ƒ‚|tttfkr|tt t fkr°td t d t d i|d   |¡}n d  |¡}dd„tdftdftdffDƒ}t|dd  |dd…¡d|dƒ‚|  ¡|  ¡|jdkr$t}|j ||j||||¡dS)Nr$rrrr'ér%gð?zunknown transformation methodz Image.BOXz Image.HAMMINGzImage.LANCZOS/Image.ANTIALIASz ({}) cannot be used.zUnknown resampling filter ({}).cSs g|]}d |d|d¡‘qS)z{} ({})rr)r)rér rrrrì… sz'Image.__transformer..z Image.NEARESTzImage.BILINEARz Image.BICUBICz Use z, rBz or )r*r-)r\ÚEXTENTÚ PERSPECTIVEr†r„rCrDrErGrHrFrrÍr¤rGr Z transform2)r{rýrÔrûrzr@r‚r_rrrrrÚxsZysraÚswÚseÚneZAsZAtrLrMrrrZ __transformerP s^        "( ( zImage.__transformercCs| ¡| |j |¡¡S)a¶ 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. )r¤ršr rT)r{rûrrrrT™ s zImage.transposecCs| ¡| |j |¡¡S)zj Randomly spread pixels in an image. :param distance: Distance to spread pixels. )r¤ršr Ú effect_spread)r{ZdistancerrrrŽ§ szImage.effect_spreadcCs$ddlm}|jstdƒ‚| |¡S)z#Returns a QImage copy of this imager)ÚImageQtzQt bindings are not installed)rYrÚqt_is_installedr[Útoqimage)r{rrrrr‘° s zImage.toqimagecCs$ddlm}|jstdƒ‚| |¡S)z$Returns a QPixmap copy of this imager)rzQt bindings are not installed)rYrrr[Ú toqpixmap)r{rrrrr’¸ s zImage.toqpixmap)NN)rÀ)rÔ)rÀ)rãNrNr)N)N)rã)N)NN)NN)N)NN)r'r')N)r4r5)r.)N)N)N)NN)RrrrÚ__doc__rÚformat_descriptionZ!_close_exclusive_fp_after_loadingr|Úpropertyr”r•rHršr›r rŸr¥r¦r²r¶r¸r¼rÁrÂrÆrµrÓrÖrÄrØr¤râÚWEBrõrïr˜Ú__copy__rþrürrr rrrrÛrrrr´rörrr!r"r&r(r/r3r6rÃrôr<rArErIrJrCrbr¬rqrurvrxryrrRr…rTrŽr‘r’rrrrr‹s          +  ' = 9           P 0 '6  & K] $ n S GSI r‹c@s eZdZdS)r.N)rrrrrrrr.Å sr.c@s eZdZdS)rƒN)rrrrrrrrƒÊ srƒcCstƒ t d¡¡S)z+Create greyscale wedge (for debugging only)r))r‹ršrlZwedgerrrrÚ_wedgeÖ sr˜cCsNt|ttfƒstdƒ‚t|ƒdkr*tdƒ‚|ddksB|ddkrJtdƒ‚dS)zª 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 zSize must be a tupler$z Size must be a tuple of length 2rrzWidth and height must be >= 0T)rgrrhr„rQ)rHrrrÚ _check_sizeÜ s r™cCs¤t|ƒ|dkr$tƒ t ||¡¡St|tƒrFddlm}|  ||¡}tƒ}|dkrt|t t fƒrt |ƒdkrddlm }|  ¡|_|j  |¡}| t |||¡¡S)a™ 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. Nr)r#r-)rr%)r—)r™r‹ršrlr™rgr%rYr#rórrhrQr—rr‚)rGrHÚcolorr#r r—rrrr™î s   "   r™rÀcGsZt|ƒt|ƒdkr*t|dtƒr*|d}|dkr>|dkr>|}t||ƒ}| |||¡|S)aˆ 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. rrrÀr)r™rQrgrhr™rÄ)rGrHrzrnror rrrrÄ s rÄcOs tdƒ‚dS)Nz?fromstring() has been removed. Please call frombytes() instead.)rÑ)rorÒrrrrØ; srØc GsŒt|ƒt|ƒdkr*t|dtƒr*|d}|dkr||dkrD|ddf}|dtkr|t|dƒ}| t |||d|¡¡}d|_ |St |||||ƒS)aä 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 rrrÀr)rr) r™rQrgrhÚ _MAPMODESr™ršrlZ map_bufferr‘rÄ)rGrHrzrnror rrrÚ frombufferA s#   rœc Cs |j}|d}t|ƒ}| dd¡}|dkr˜yd|dd…|df}Wntk rbtdƒ‚YnXyt|\}}Wqœtk r”td|ƒ‚YqœXn|}|d krªd}n|d kr¸d }nd }||krÔtd ||fƒ‚|d|df} |dk r t|dƒr| ¡}n|  ¡}t || |d|ddƒS)a¨ 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 r½ÚstridesN)rrr$r¾zCannot handle this data typez$Cannot handle this data type: %s, %s)r*r)r+r-r,r.rr%zToo many dimensions: %d > %d.rrrµrÀ) rÁrQrírjrƒÚ_fromarray_typemapr„r!rµrÓrœ) ÚobjrGZarrr½ÚndimrZtypekeyrÜZndmaxrHrrrÚ fromarrayv s6    r¡cCs$ddlm}|jstdƒ‚| |¡S)z-Creates an image instance from a QImage imager)rzQt bindings are not installed)rYrrr[Ú fromqimage)r rrrrr¢² s r¢cCs$ddlm}|jstdƒ‚| |¡S)z.Creates an image instance from a QPixmap imager)rzQt bindings are not installed)rYrrr[Ú fromqpixmap)r rrrrr£» s r£)r*z1;8)r)r))r+zI;8)r+zI;16)r+zI;16B)r+zI;16S)r+zI;16BS)r+zI;32)r+zI;32B)r+zI;32S)r+zI;32BS)r,zF;32F)r,zF;32BF)r,zF;64F)r,zF;64BF)rErE)r.r.)r<r<)))rrz|b1))rrz|u1))rrz|i1))rrzu2))rrzi2))rrzu4))rrzi4))rrzf4))rrzf8))rrr$z|u1))rrrz|u1))rrr%z|u1)r+r+)rr)r,r,cCs\tdkr dS|d|d}|dtkr|dkrtd|ƒ‚nt|tjƒr*tdƒ‚d‰d}t|tƒrJt| ¡ƒ}n t|ƒrV|}|rjt  |d¡}d‰y|  d¡Wn,t tj fk r¤t  | ¡¡}d‰YnX| d ¡}tƒg‰‡‡fd d „}||||ƒ}|d krîtƒrî||||ƒ}|rüˆ|_|Sˆr | ¡xˆD]}t |¡qWtd |r2|n|ƒ‚d S)aÛ 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 FileNotFoundError: If the file cannot be found. :exception PIL.UnidentifiedImageError: If the image cannot be opened and identified. :exception ValueError: If the ``mode`` is not "r", or if a ``StringIO`` instance is used for ``fp``. r¥z bad mode %rzKStringIO cannot be used to open an image. Binary data must be used instead.FrYÚrbTréc s´x®tD]¦}y`t|\}}| p$||ƒ}t|ƒttgkrBˆ |¡n&|rh| d¡|||ƒ}t|jƒ|SWqt t t t j fk rŠwYqtk rªˆr¤| ¡‚YqXqWdS)Nr)ÚIDrbÚtyper%rðrËrqrrHÚ SyntaxErrorÚ IndexErrorrƒÚstructÚerrorÚ BaseExceptionrŸ)rœr±ÚprefixrêÚfactoryÚacceptr,r )Úaccept_warningsÚ exclusive_fprrÚ _open_core* s$       zopen.._open_coreNzcannot identify image file %r)r„rgr¹ÚStringIOrr%ÚresolverrkrlrqrÚUnsupportedOperationrºÚreadr\rerrŸrñròr)rœrGr±r¯r´r rLr)r²r³rrlô sH        rlcCs&| ¡| ¡| t |j|j¡¡S)zù 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. )r¤ršrlr(r )Úim1Úim2rrrr(X s r(cCs(| ¡| ¡| t |j|j|¡¡S)aŒ 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. )r¤ršrlÚblendr )r¹rºr2rrrr»g sr»cCs| ¡}| |d|¡|S)af 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)r˜r&)Zimage1Zimage2r rÔrrrÚ composite~ s r¼cGs| |d¡S)aá 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. r)r/)rÔrorrrÚeval s r½cCsžt|ƒt|ƒksd|kr tdƒ‚xB|dd…D]2}|jt|ƒkrHtdƒ‚|j|djkr.tdƒ‚q.Wx|D] }| ¡qjW|d tj |fdd „|DƒžŽ¡S) am 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. Ú*zwrong number of bandsrNz mode mismatchrz size mismatchcSsg|] }|j‘qSr)r )rér‡rrrrì´ szmerge..) rRrQr„rGrNrHr¤ršrlr )rGrOrrrrr Ÿ s    r cCs"| ¡}t |¡||ft|<dS)a1 Register an image file plugin. This function should not be used in application code. :param id: An image format identifier. :param factory: An image file factory method. :param accept: An optional function that can be used to quickly reject images having another format. N)rir¨rËrb)r·r°r±rrrÚ register_open» s  r¿cCs|t| ¡<dS)zÈ Registers an image MIME type. This function should not be used in application code. :param id: An image format identifier. :param mimetype: The image MIME type for this format. N)ÚMIMEri)r·ÚmimetyperrrÚ register_mimeÊ srÂcCs|t| ¡<dS)zÏ Registers an image save function. This function should not be used in application code. :param id: An image format identifier. :param driver: A function to save images in this format. N)rcri)r·ÚdriverrrrÚ register_saveÕ srÄcCs|t| ¡<dS)zü Registers an image function to save all the frames of a multiframe format. This function should not be used in application code. :param id: An image format identifier. :param driver: A function to save images in this format. N)rjri)r·rÃrrrÚregister_save_allà s rÅcCs| ¡t| ¡<dS)zÇ Registers an image extension. This function should not be used in application code. :param id: An image format identifier. :param extension: An extension used for this format. N)rirhrg)r·Ú extensionrrrÚregister_extensionì srÇcCsx|D]}t||ƒqWdS)zÎ Registers image extensions. This function should not be used in application code. :param id: An image format identifier. :param extensions: A list of extensions used for this format. N)rÇ)r·Ú extensionsrÆrrrÚregister_extensions÷ s rÉcCsts tƒtS)za Returns a dictionary containing all file extensions belonging to registered plugins )rhrerrrrÚregistered_extensions srÊcCs |t|<dS)a Registers an image decoder. This function should not be used in application code. :param name: The name of the decoder :param decoder: A callable(mode, args) that returns an ImageFile.PyDecoder object .. versionadded:: 4.1.0 N)ri)rrprrrÚregister_decoder s rËcCs |t|<dS)a Registers an image encoder. This function should not be used in application code. :param name: The name of the encoder :param encoder: A callable(mode, args) that returns an ImageFile.PyEncoder object .. versionadded:: 4.1.0 N)rs)rrurrrÚregister_encoder s rÌcKst|f|ŽdS)N)Ú_showxv)rÔr®rrrrt- srtcKs ddlm}|j||f|ŽdS)Nr)Ú ImageShow)rYrÎru)rÔrrr®rÎrrrrÍ2 s rÍcCstƒ t |||¡¡S)a Generate a Mandelbrot set covering the given extent. :param size: The requested size in pixels, as a 2-tuple: (width, height). :param extent: The extent to cover, as a 4-tuple: (x0, y0, x1, y2). :param quality: Quality. )r‹ršrlÚeffect_mandelbrot)rHZextentZqualityrrrrÏ< s rÏcCstƒ t ||¡¡S)z» Generate Gaussian noise centered around 128. :param size: The requested size in pixels, as a 2-tuple: (width, height). :param sigma: Standard deviation of noise. )r‹ršrlÚ effect_noise)rHÚsigmarrrrÐI srÐcCstƒ t |¡¡S)zl Generate 256x256 linear gradient from black to white, top to bottom. :param mode: Input mode. )r‹ršrlÚlinear_gradient)rGrrrrÒT srÒcCstƒ t |¡¡S)zm Generate 256x256 radial gradient from black to white, centre to edge. :param mode: Input mode. )r‹ršrlÚradial_gradient)rGrrrrÓ] srÓc Cs|dkrtj}xîdtjfdtjfdtjfgD]Î\}}||kr>q,|| ¡}d}x0dD](\}}| |¡rT|}|dt|ƒ …}qTWyt |ƒ|}Wn&t k r¶t   d  |¡¡w,YnXy ||ƒWq,t k rø}zt   d  ||¡¡Wdd}~XYq,Xq,WdS)NZPILLOW_ALIGNMENTZPILLOW_BLOCK_SIZEZPILLOW_BLOCKS_MAXr))Úki)ræiz {} is not intz{}: {})rªÚenvironrlZ set_alignmentZset_block_sizeZset_blocks_maxrgr«rQrÝr„rñròr)ÚenvÚvar_nameÚsetterÚvarZunitsZpostfixÚmulrdrrrÚ_apply_env_variablesj s.   rÛc@s‚eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS)!rrBcCsi|_i|_d|_d|_dS)N)Ú_dataÚ_ifdsÚ_infoÚ _loaded_exif)r{rrrr|‘ sz Exif.__init__cCs<y"t|ƒdkr t|tƒs |dSWntk r6YnX|S)Nrr)rQrgÚdictr¢)r{rxrrrÚ_fixup— s  z Exif._fixupcs‡fdd„| ¡DƒS)Ncsi|]\}}ˆ |¡|“qSr)rá)rérÔrç)r{rrú ¢ sz$Exif._fixup_dict..)Úitems)r{Zsrc_dictr)r{rÚ _fixup_dictŸ szExif._fixup_dictc Cs`y|j ||¡Wnttfk r,Yn0Xddlm}| |j¡}| |j¡|  |¡SdS)Nr)ÚTiffImagePlugin) rœrqrjrƒrYråÚImageFileDirectory_v1Úheadr¤rä)r{ÚtagrårŽrrrÚ _get_ifd_dict¤ s   zExif._get_ifd_dictcCsÂ||jkrdS||_|j ¡|j ¡d|_|s6dSt |dd…¡|_|j d¡|_ ddl m }|  |j ¡|_|jj |_|j |jj¡|j |j¡| d¡}|r¾|j |¡||jd<dS)Nr'r‡r)råii‡)rßrÜÚclearrÝrÞr¹rºrœr¸rçrYråræÚ_endianÚendianrqÚnextr¤réÚupdate)r{rzråÚifdrrrr¤² s&       z Exif.loadrcCs\ddlm}|jdkrd}nd}|j|d}x| ¡D]\}}|||<q6Wd|| |¡S)Nr)rårBsII*sMM*)ZifhsExif)rYrårìÚImageFileDirectory_v2rãrµ)r{r"rårçrïrèrxrrrrµÒ s    z Exif.tobytesc Cs||jkr||kr|dkr2| |¡|j|<nÖ|dkrddlm}|ddd…dkr¬|d}t|dd…ƒ}||d…}i}x tdt d |dd …¡dƒD]è}t d ||dd |ddd …¡\}} } } y|j| \} } Wnt k rw¨YnX| | }|d krBt d | ¡\}||d||d…} n | d|…} t | ƒ|krvt   d|t | ƒ|f¡q¨| s~q¨| |ƒ| dƒ||<q¨Wt | |¡ƒ|jd<n\| d¡dkr|d}i}x2tdt d|dd …¡dƒD]}t d||dd |ddd …¡\}} } } |dkrêt d| ¡\}|j |¡d|j d ¡i}|j d ¡t|j d¡ƒ|d<|j d ¡|j d ¡|d<|j d¡|j d ¡}|jtjd} | |ƒ|dƒ|d<|j d ¡|j d ¡|d<dt | |¡ƒi}qêW||jd<|j |i¡S)N)i%ˆi i|’r)rðr‡sFUJIFILMé rzHz>HHL4siz>LZModelIDZ TimeStampZInternalSerialNumberZParallaxZCategory)rÝrérårðr rîr¬ÚunpackZ_load_dispatchrjrQrñròràrärírœrqr¸rÚFLOAT)r{rèrðZ exif_dataZ ifd_offsetZifd_dataZ makernoterêZifd_tagrIÚcountrzZ unit_sizeÚhandlerrHr"Z camerainfoZparallaxrrrÚget_ifdÞ sv   &,  (,        z Exif.get_ifdcCs0|jdk r&x|j ¡D] }||qWt|jƒS)N)rÞÚkeysr%rÜ)r{rèrrrÚ__str__2 s  z Exif.__str__cCs(t|jƒ}|jdk r | |j¡t|ƒS)N)ÚsetrÜrÞrîrQ)r{r÷rrrÚ__len__: s   z Exif.__len__cCs^|jdk rT||jkrT||jkrT| |j|¡|j|<|dkrL| |¡|j|<|j|=|j|S)Ni%ˆ)rÞrÜrárö)r{rèrrrÚ __getitem__@ s zExif.__getitem__cCs||jkp|jdk o||jkS)N)rÜrÞ)r{rèrrrÚ __contains__H szExif.__contains__cCs*|jdk r||jkr|j|=||j|<dS)N)rÞrÜ)r{rèrxrrrÚ __setitem__K szExif.__setitem__cCs(|jdk r||jkr|j|=|j|=dS)N)rÞrÜ)r{rèrrrÚ __delitem__P szExif.__delitem__cCs(t|jƒ}|jdk r | |j¡t|ƒS)N)rùrÜrÞrîÚiter)r{r÷rrrÚ__iter__U s   z Exif.__iter__N)r)rrrrìr|rárärér¤rµrörørúrûrürýrþrrrrrrŽ s Tr)r)r)r)rÀ)rÀ)N)r¥)N)N)N)¡Úatexitrkr¹Úloggingr>rrªr¬Úsysr¨rñÚcollections.abcrrZpathlibrrYrrrr r r Ú_binaryr r Z_utilrrÚ version_inforrrZÚ getLoggerrr]ÚRuntimeWarningrr¢rrÝr¤rrlrkr[rçr%Ú startswithròr!ráràr#ÚNONEZFLIP_LEFT_RIGHTZFLIP_TOP_BOTTOMrVrUrWZ TRANSPOSEZ TRANSVERSEr\rˆr‰r†r„rCrGrDZLINEARrHrEZCUBICrFZ ANTIALIASr=ZORDEREDZ RASTERIZErør–r÷Z MEDIANCUTZ MAXCOVERAGEZ FASTOCTREEZ LIBIMAGEQUANTrZSEQUENCEZ CONTAINERr(ZFILTEREDZ HUFFMAN_ONLYZRLEZFIXEDr¨rbrÀrcrjrhrirsZ _MODEINFOÚ byteorderZ_ENDIANrFrKÚsortedZMODESr›rMrNrPrRrXr\rerqrvryrwrŠr‹r.rƒr˜r™r™rÄrØrœr¡r¢r£ržrrlr(r»r¼r½r r¿rÂrÄrÅrÇrÉrÊrËrÌrtrÍrÏrÐrÒrÓrÛÚregisterÚ clear_cacherrrrrÚs¶                 .   S  ' & 5 <   d