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ddfe%d2dfd0dfff6ddfe$d2dfdd0fff6ddfe%d2dfdd0fff6ddfe$d2dfd0d0fff6ddfe%d2dfd0d0fff6ddfe$d2dfdd4fff6ddfe%d2dfdd4fff6ddfe$d2dfd0d4fff6ddfe%d2dfd0d4fff6ddfe$d2dfdd<fff6ddfe%d2dfdd<fff6ddfe$d2dfdd<d<fd0ff6ddfe%d2dfdd<d<fd0ff6ddfe$d2dfd0d<fff6ddfe%d2dfd0d<fff6ddfe$d6dfdd<d<d<d<fff6ddfe%d6dfdd<d<d<d<fff6ddfe$d6dfdd<d<d<d<d<fdLff6ddfe%d6dfdd<d<d<d<d<fdLff6ddfe$d6dfdd<d<d<d<d<d<fdLdLff6ddfe%d6dfdd<d<d<d<d<d<fdLdLff6dkdkfe$d8dfdd<d<d<fff6dkdkfe%d8dfdd<d<d<fff6ddfe$d<dfdd<d<d<fff6ddfe%d<dfdd<d<d<fff6ZIddddgZJdZKdZLiZMiZNdefdYZOdefdYZPeMeP_MeNeP_Nx`ejGD]R\ZQZReRjSddZReTePdeReMeQdeTePdeReNeQqYW[M[N[Q[RdePfdYZUeUZVdejfdYZWidJe$dddfeXfdJ6dOe$ddd<feXfdO6dje$ddd<d<fd0fdj6de$d2dd<feXfd6de$d2dd<d<fd0fd6dhe$dd0defeXfd`6d[e$ddd^feXfd[6dae$dd0d^feXfda6dde$dd2defeXfdc6dke$d0dd<d<d<feXfdk6dne$d0dd<d<d<d<fdLfdn6dme$d0dd<d<d<d<fd0fdm6de$d6dd<d<d<d<feXfd6de$d8dd<d<d<feXfd6de$d<dd<d<d<feXfd6die%dd0defeXfdi6d_e%ddd^feXfd_6dbe%dd0d^feXfdb6dfe%dd2defeXfdf6ZYdZZdfdYZ[dZ\ej]eWj^eWeKej_eWj^eZej`eWj^e\ejaeWj^ddgejbeWj^ddS(i(tdivisiontprint_functioni(tImaget ImageFilet ImagePalettetTiffTags(ti8to8(tpy3(tFraction(tNumbertRationalN(tTYPES(tMutableMappings1.3.5tIItMMiiiiii iiiiiiiii(i1i2i;i=i@iDiRiSi[iiiIisiiiiitrawt tiff_ccittitgroup3itgroup4ittiff_lzwit tiff_jpegitjpegittiff_adobe_deflateit tiff_raw_16itpackbitsittiff_thunderscani)t tiff_deflateit tiff_sgilogitt tiff_sgilog24iucC si|]\}}||qS(((t.0tktv((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys s t1s1;Iis1;IRs1;RtLsL;2IsL;2IRsL;2sL;2RsL;4IsL;4IRsL;4sL;4RsL;IsL;IRsL;RsI;16sI;12i isI;16BtIsI;16SsI;16BStFsF;32Fi sF;32BFsI;32NsI;32SsI;32BStLAtRGBsRGB;RtRGBAtRGBXtRGBXXtRGBXXXtRGBatRGBaXtRGBaXXtRGBAXtRGBAXXisRGB;16LsRGB;16BsRGBA;16LsRGBA;16BsRGBX;16LsRGBX;16BsRGBa;16LsRGBa;16BtPsP;1sP;1RsP;2sP;2RsP;4sP;4RtPAsP;RtCMYKtCMYKXtCMYKXXtLABsMM*sII*sMM*sII*cC s|d tkS(Ni(tPREFIXES(tprefix((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt_acceptscC sRt|dk}t|r%d|n|j|}|rN|dddS|S(Nii(tabst IFDRationaltlimit_rational(tvaltmax_valtinvtn_d((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt_limit_rationals%R:cB seZdZd)ZddZedZedZdZd Z d Z d Z d Z e d Z e dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe d Z e d!Z!e d"Z"e d#Z#e d$Z$e d%Z%e d&Z&e d'Z'e d(Z(RS(*s Implements a rational class where 0/0 is a legal value to match the in the wild use of exif rationals. e.g., DigitalZoomRatio - 0.00/0.00 indicates that no digital zoom was used t _numeratort _denominatort_valicC s||_||_td|_t|trT|j|_|j|_||_nt|tr|j|_|j|_|j|_dS|dkrtd|_dS|dkrt||_nt|||_dS(s :param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator iNitnan( RBRAtfloatRCt isinstanceR t numeratort denominatorR:(tselftvalueRH((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__init__4s$          cC s|jS(N(RA(ta((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRGRscC s|jS(N(RB(RL((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRHVscC sA|jdkr|j|jfS|jj|}|j|jfS(s :param max_denominator: Integer, the maximum denominator value :returns: Tuple of (numerator, denominator) i(RHRGRCtlimit_denominator(RItmax_denominatortf((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR;ZscC stt|jS(N(tstrRERC(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__repr__gscC s |jjS(N(RCt__hash__(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRRjscC s |j|kS(N(RC(RItother((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__eq__msc sfd}|S(Nc st|j|S(N(tgetattrRC(RItargs(top(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytdelegateqs((RWRX((RWs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt _delegatepst__add__t__radd__t__sub__t__rsub__t__div__t__rdiv__t__mul__t__rmul__t __truediv__t __rtruediv__t __floordiv__t __rfloordiv__t__mod__t__rmod__t__pow__t__rpow__t__pos__t__neg__t__abs__t __trunc__t__lt__t__gt__t__le__t__ge__t __nonzero__t__ceil__t __floor__t __round__(RARBRC()t__name__t __module__t__doc__t __slots__RKtpropertyRGRHR;RQRRRTRYRZR[R\R]R^R_R`RaRbRcRdReRfRgRhRiRjRkRlRmRnRoRpRqRrRsRtRu(((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR:&sL                               tImageFileDirectory_v2c B s(eZdZdd>dZedZedZedZej dZdZ dZ d Z d Z d Zd Zesd ZndZdZdZdZdZdZdZdZdZeeed?d@dAdBdCdDdEged,d,ed-Zed,d.Zed/d,ed0Z ed/d1Z!ed2d ed3Z"ed2d4Z#ed5d,ed6Z$ed5d7Z%ed8d ed9Z&ed8d:Z'd;Z(d<Z)d=Z*RS(FsThis class represents a TIFF tag directory. To speed things up, we don't decode tags unless they're asked for. Exposes a dictionary interface of the tags in the directory:: ifd = ImageFileDirectory_v2() ifd[key] = 'Some Data' ifd.tagtype[key] = 2 print(ifd[key]) 'Some Data' Individual values are returned as the strings or numbers, sequences are returned as tuples of the values. The tiff metadata type of each item is stored in a dictionary of tag types in `~PIL.TiffImagePlugin.ImageFileDirectory_v2.tagtype`. The types are read from a tiff file, guessed from the type added, or added manually. Data Structures: * self.tagtype = {} * Key: numerical tiff tag number * Value: integer corresponding to the data type from ~PIL.TiffTags.TYPES` .. versionadded:: 3.0.0 sII*cC s|d tkr#td|n|dk r5|n|d |_|jtkr]d|_n'|jtkrxd|_n td|j|jd|d\|_ t |_ dS( sInitialize an ImageFileDirectory. To construct an ImageFileDirectory from a real file, pass the 8-byte magic header to the constructor. To only set the endianness, pass it as the 'prefix' keyword argument. :param ifh: One of the accepted magic headers (cf. PREFIXES); also sets endianness. :param prefix: Override the endianness of the file. is%not a TIFF file (header %r not valid)it>tscC s|jS(N(t_offset(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC s|jS(N(R(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC stddS(Ns"Not allowing setting of legacy api(t Exception(RIRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt legacy_apiscC s:i|_i|_i|_i|_d|_d|_dS(N(t_tags_v1t_tags_v2t_tagdatattagtypeRt_nextR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs      cC stt|S(N(RPtdict(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__str__scC std|jDS(s :returns: dict of name|key: value Returns the complete tag dictionary, with named tags where possible. cs s-|]#\}}tj|j|fVqdS(N(Rtlookuptname(RtcodeRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys s(Rtitems(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytnameds cC s tt|jt|jBS(N(tlentsetRR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__len__scC s||jkrX|j|}|j|}|j|\}}||||j||*sics s|]}t|tVqdS(N(RFtint(RR ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys ,scs s|]}|dkVqdS(iiNi((RR ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys -siics s|]}t|tVqdS(N(RFRE(RR ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys 1si cs s|]}t|tVqdS(N(RFRP(RR ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys 5sitasciitreplacec3 s|]}j|VqdS(N(tcvt_enum(RRJ(tinfo(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys Bsii s=Metadata Warning, tag %s had too many entries: %s, expected 1i(ii (R RRPRtunicodeRRRFRttypetalltencodeRRERRRtlengthRRt ValueErrortwarningstwarn(RIRRJRt basetypestvaluesR tdest((Rs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRsR  *4(  cC s=|jj|d|jj|d|jj|ddS(N(RtpopRRR(RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt __delitem__^scC s tt|jt|jBS(N(titerRRR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__iter__cscC stj|j||S(N(tstructtunpackR(RItfmtR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRfscG stj|j||S(N(RtpackR(RIRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt_packisc sfd}|S(Nc sVddlm}|jjdrB|jdjdd|s(tjoin(RIR(R(RIs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs(RR RtcalcsizetTrueRR(t idx_fmt_nameR RR((RRs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt_register_basic{s  itHtshortiR"tlongitbs signed byteiths signed shorti tls signed longi ROREi tdtdoubleicC s|S(N((RIRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt load_bytescC s|S(N((RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt write_bytesicC s,|jdr|d }n|jddS(Nsislatin-1R(tendswithtdecode(RIRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt load_strings cC s?tjjdkr'|jdd}nd|jdddS(NiRRRs(tsyst version_infotmajorRR(RIRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt write_stringsic sq|jdjt|d|}fdtfdt|ddd|dddDS(Ns{}Lic sr||fSt||S(N(R:(RLR(R(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytcombinesc3 s$|]\}}||VqdS(N((Rtnumtdenom(R(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys sii(RRRRtzip(RIRRtvals((RRs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt load_rationals%c sdjfd|DS(NRc3 s*|] }jdt|dVqdS(t2LiiNI(RR@(Rtfrac(RI(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys s(R(RIR((RIs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytwrite_rationalsicC s|S(N((RIRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytload_undefinedscC s|S(N((RIRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytwrite_undefinedsi c sq|jdjt|d|}fdtfdt|ddd|dddDS(Ns{}lic sr||fSt||S(N(R:(RLR(R(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRsc3 s$|]\}}||VqdS(N((RRR(R(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys sii(RRRRR(RIRRR((RRs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytload_signed_rationals%c sdjfd|DS(NRc3 s*|] }jdt|dVqdS(RiiNi@(RR@(RR(RI(s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pys s(R(RIR((RIs3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytwrite_signed_rationalscC sH|j|}t||krDtdd|t|fn|S(NsCorrupt EXIF data. s,Expecting to read %d bytes but only got %d. (treadRtIOError(RItfpRtret((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt _ensure_reads cC s|j|j|_y>xt|jd|j|ddD]}|jd|j|d\}}}}trtj|j }t j |d}t d||||fdd ny|j |\} } Wn*tk rtrEt d |qEqEnX|| } | d kr|j} |jd |\} tr`t d | | fdd n|j| tj|| }|j| n || }t|| krtjd| t||fqEn|sqEn||j|<||j|s- value:(RttellRtrangeRRtDEBUGRRRR tgettprintRtKeyErrortseekRt _safe_readRRRRRRRRP(RIRtiRRtcountRttagnamettypnamet unit_sizeRRtheretoffsettmsg((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytloadsX / !          (c C s|jdkr8|j|j|jdddn|j|jdt|jg}|jt|jdd}d}xt|jjD]\}}|t krt|}n|j j |}t rt d|||fnt|tr |n|f}|j|||} t rtj|j} tj |d } t d | || |fd d t| d krt dt| qt d|n|dkrt| n t|} t| dkr|j||| | jdddfq|j||| |jd|| f|t| ddd7}qW|dk r||\}}} }} | rtdn|jd|jd|d|}||| || f||s- value:iisRR"is&multistrip support not yet implementedRs(ii(RtwriteRRRRRtsortedRt STRIPOFFSETSRRRRRFRRRRRR tappendtljusttNotImplementedErrorRtrepr( RIRtentriesRt stripoffsetsRRJRRRRRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytsavesZ&"!" $+    & %&  N(iRR(iR"R(iRs signed byte(iRs signed short(i Rs signed long(i RORE(i RR(+RvRwRxRRKRzR7RRtsetterRRRRRRRRRRRRRRRRRtlisttmapRRRRRRRRRRRRR R(((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR{sb       A              9RRRtwrite_tImageFileDirectory_v1cB szeZdZdZedZedZedZdZ dZ dZ dZ d Z d ZRS( sThis class represents the **legacy** interface to a TIFF tag directory. Exposes a dictionary interface of the tags in the directory:: ifd = ImageFileDirectory_v1() ifd[key] = 'Some Data' ifd.tagtype[key] = 2 print(ifd[key]) ('Some Data',) Also contains a dictionary of tag types as read from the tiff image file, `~PIL.TiffImagePlugin.ImageFileDirectory_v1.tagtype`. Values are returned as a tuple. .. deprecated:: 3.0.0 cO s tj|||t|_dS(N(R{RKRR(RIRVtkwargs((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRKhscC s|jS(N(R(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRlscC s|jS(N(R(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRmscC s:|d|j}|j|_|j|_|j|_|S(s3 Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` R7(R7RRR(tclstoriginaltifd((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytfrom_v2os    cC sLtd|j}t|j|_t|j|_t|j|_|S(s3 Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` R7(R{R7RRRR(RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytto_v2s cC s||jkp||jkS(N(RR(RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC s tt|jt|jBS(N(RRRR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC s tt|jt|jBS(N(RRRR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC s.x'ttfD]}|j|||q WdS(N(RRR(RIRRJR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC s||jkru|j|}|j|}|j|\}}x6ttfD]%}|j||||||qIWn|j|}t|tt fs|f}n|S(N( RRRRRRRRFRR(RIRRRRRtlegacyR<((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs  &  (RvRwRxRKRzttagsttagdatat classmethodRRRRRRR(((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRVs      t TiffImageFilecB seZdZdZeZdZedZedZ dZ dZ dZ edZ e jd Z d Zd Zd Zd ZRS(tTIFFs Adobe TIFFcC s|jjd}t||_d|_|_|jj|_|_ d|_ |j|_ g|_ d|_ d|_trtdtd|jtd|n|jddS(s#Open the first image in a TIFF fileiis*** TiffImageFile._open ***s - __first:s- ifh: iN(RRR{ttag_v2RRRRt_TiffImageFile__firstt_TiffImageFile__nextt_TiffImageFile__framet_TiffImageFile__fpt _frame_post _n_framest _is_animatedRRt_seek(RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt_opens      cC s|jdkrz|j}y(x!trA|j|jdq!WWn$tk ri|jd|_nX|j|n|jS(Ni(R,RRRR.tEOFErrorR(RItcurrent((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytn_framess   cC s|jdkr|jdk r3|jdk|_q|j}y|jdt|_Wntk rut|_nX|j|n|jS(Ni(R-RR,RRRR0R(RIR1((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt is_animateds     cC sR|j|sdS|j|tj|jtjj|j|j|_dS(s%Select a given frame as current imageN( t _seek_checkR.Rt_decompression_bomb_checkRtcoretnewtmodetim(RItframe((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs  cC sb|j|_xt|j|kr|js<tdntrntd||j|j|jj fn|jj |jj |j|jj |jtrtd|jj n|j j |j|j j|_|jd7_qW|jj |j||j j |j|j j|_tj|j |_|_||_|jdS(Nsno more images in TIFF files9Seeking to frame %s, on frame %s, __next %s, location: %ssLoading tags, location: %si(R*RRR+R(R0RRR)RRRR&R RRRRRt_setup(RIR:((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR.s*  &  cC s|jS(sReturn the current frame number(R)(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC s|jS(N(t_size(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRscC stjdt||_dS(NsSetting the size of a TIFF image directly is deprecated, and will be removed in a future version. Use the resize method instead.(RRtDeprecationWarningR<(RIRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR scC s&|jr|jStt|jS(N(tuse_load_libtifft _load_libtifftsuperR$R (RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR )s  cC s)|jdkr%|j r%t|_ndS(Ni(R)R(Rt!_close_exclusive_fp_after_loading(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytload_end.scC stjj|}|jdkr0tdn|js=|S|jt|jdksktdn|jdd}t|jdd|jj g}yPt |j dot j |j j}t |j dr|j jnWntk r t}nX|r||d|D]}|||kr|t*|d}nd}| }|jd kr| |}||}n|t+|df}|j!j&|j||t|||t|||f||f||}||jdkrhd||}}||jdkr|d}}|d7}q|qhqhWnt rt d$ntd%t,|jkr|jt,|jd&RRRR t TILEOFFSETSt ROWSPERSTRIPtsumRt ICCPROFILEtCOLORMAPRRRRtpalette(RItphotot fillordertxsizetysizet sampleFormatt bps_tuplet extra_tuplet bps_counttkeytrawmodetxrestyrestresunittxtytlayerRLtoffsetsRtwRtstridet tile_rawmodeRRt((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR;s   (     $                      )     *(RvRwRtformat_descriptionRRAR/RzR2R3RR.RRRR RBR?R;(((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR$s       WtYCbCrc C sy#t|j\}}}}}}Wn$tk rItd|jnXtd|} |jjd|jjd} | dkrd} nt p| dk} t |dd| t <|j d| t <|j d| t<|jjdi} tr td t| nt| tr)| j} nxC| D];} | j| | | j?kr"qn||kr||krt|t@rLtAntBrr|jCd!d"d#||siisSaving using libtiff encoders Items: %sRCRRRssConverted items: %ssI;16BsI;16sI;16NREiis(encoder error %d when writing image filet_debug_multipage(i(sI;16BsI;16(iii@(ii(Pt SAVE_INFOR8RRR{t encoderinfoRRRt WRITE_LIBTIFFRUR_RRcRdRRRRFRRRRJRmRkRltIPTC_NAA_CHUNKtPHOTOSHOP_CHUNKtXMPR&RrtIMAGEDESCRIPTIONtSOFTWAREt DATE_TIMEtARTISTt COPYRIGHTRhRtSAMPLESPERPIXELRiReRaR9t getpaletteRRsRptSTRIPBYTECOUNTSR tCOMPRESSION_INFO_REVR]R RRRKRLRCtiotUnsupportedOperationRt itertoolstchainRt LIBTIFF_CORERRPRRR:RERt _getencodert encoderconfigRORR RRt_saveR(R9RtfilenameR~R7RuRtbitstextraRRXRERR}RRYtlutRt_fpt blocklisttattst legacy_ifdRRJRLteRtsRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRhs# !    !                 '        &tAppendingTiffWriterc B seZdddddddddddddg Zddddd d hZed Zd Zd ZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZdZdZdZdZeed ZRS(!iiiiiii iDiii cC st|dr$||_t|_n`||_t|_y%tj||rNdnd|_Wn&tk rtj|d|_nX|jj |_ |j dS(NRsw+bsr+b( RJRORtclose_fpRRRtopenRRt beginningtsetup(RItfnR7((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRK)s    % cC s|jj|jtjd|_d|_|jjd|_ }|sWt |_ dSt |_ |dkr||j dn(|dkr|j dn td|j|jdS(NiisII*R}sMM*R|sInvalid TIFF file header(RORRRKtSEEK_SETRtwhereToWriteNewIFDOffsettoffsetOfNewPageRtIIMMRtisFirstRt setEndiant RuntimeErrortskipIFDstgoToEnd(RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR7s        cC s|jr dS|jj|j|jjd}|s<dS||jkrZtdn|j}||j7}|jj|j|j ||jj||j dS(Nis1IIMM of new page doesn't match IIMM of first page( RRORRRRRtreadLongRt writeLongtfixIFD(RIRt IFDoffset((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytfinalizeOs    cC s|j|jdS(N(RR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytnewFramegs cC s|S(N((RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt __enter__lscC s|jr|jntS(N(RRRR(RItexc_typet exc_valuet traceback((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt__exit__os  cC s|jj|jS(N(RORR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRtscC s<|tjkr||j7}n|jj|||jS(N(RKRRRORR(RIRtwhence((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRwscC s|jjdtj|jj}d|d}d|koJdknrn|jjtt|n|jj|_dS(Nii( RORRKtSEEK_ENDRR Rt bytearrayR(RItpostpadBytes((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR~s cC s=||_|jd|_|jd|_|jd|_dS(NR"RtHHL(tendiantlongFmttshortFmtt tagFormat(RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs cC syxrtrt|j}|dkr;|jjd|_Pn|jj||j}|jj|dtjqWdS(Niii ( RRRORRRt readShortRKtSEEK_CUR(RIRtnumTags((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs    cC s|jj|S(N(ROR (RIR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyR scC s(tj|j|jjd\}|S(Ni(RRRROR(RIRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs$cC s(tj|j|jjd\}|S(Ni(RRRROR(RIRJ((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs$cC sf|jjdtj|jjtj|j|}|dk rb|dkrbt d|ndS(Niis wrote only %u bytes but wanted 4( RORRKRR RRRRR(RIRJt bytesWritten((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytrewriteLastShortToLongs !cC sf|jjdtj|jjtj|j|}|dk rb|dkrbt d|ndS(Niis wrote only %u bytes but wanted 2( RORRKRR RRRRR(RIRJR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytrewriteLastShorts !cC sf|jjdtj|jjtj|j|}|dk rb|dkrbt d|ndS(Niis wrote only %u bytes but wanted 4( RORRKRR RRRRR(RIRJR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pytrewriteLastLongs !cC sP|jjtj|j|}|dk rL|dkrLtd|ndS(Nis wrote only %u bytes but wanted 2(ROR RRRRR(RIRJR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt writeShorts!cC sP|jjtj|j|}|dk rL|dkrLtd|ndS(Nis wrote only %u bytes but wanted 4(ROR RRRRR(RIRJR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs!cC s|j|jjdS(N(RRORR(RI((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRRs c C st|j}xat|D]S}tj|j|jjd\}}}|j|}||}|dk}|s|j} | |j 7} |j | n||j krM|jj } |r|j |d|dkd|dk|jj| dnE|jj| |j |d|dkd|dk|jj| d} } q|r|jjdtjqqWdS(NiitisShortitisLong(RRRRRRORt fieldSizesRRRtTagsRt fixOffsetsRRRKR( RIRRRt fieldTypeRt fieldSizet totalSizetisLocalRtcurPos((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs0          cC s| r| rtdnxt|D]}|rB|jn |j}||j7}|r|dkr|dkrtdn|j||jjdtj |j d|jjdtj q*|r|j |q*|j |q*WdS(Ns offset is neither short nor longiisnot implementediii( RRRRRRRORRKRRRR(RIRRRRR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRs    (RvRwRRRRKRRRRRRRRRRR RRRRRRRRRRR(((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyRsH                    "c C s$|jj}|j}t|jdg}t|d rW| rWt|||S|j}zt|}x|g|D]}||_||_t|dsd} n |j } xEt | D]7} |j | |j t||||j qWqWWdQXWd|j |XdS(Nt append_imagesR2i(RtcopyRRRRJRRRR2RRR R( R9RRRRRtcur_idxttftimstnfrR((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt _save_alls(        s.tifs.tiffs image/tiff(ct __future__RRRRRRRt_binaryRRt_utilRt fractionsR tnumbersR R RRRKRRRR tcollections.abcR t ImportErrort collectionst __version__RRRnRRtIFD_LEGACY_APIRRRcRdRhR]RaRbRR RRpRRkRlR_RmRRRt PREDICTORRsRoRiRet JPEGTABLESRRRRrtEXIFIFDRtIMAGEJ_META_DATA_BYTE_COUNTStIMAGEJ_META_DATAR\RRRjR6R8R@RRR:R{RRRtsetattrRtImageFileDirectoryR$RRRRRt register_openRt register_savetregister_save_alltregister_extensionst register_mime(((s3/tmp/pip-build-SKekGm/pillow/PIL/TiffImagePlugin.pyt*s"        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%++++++..1177==1177==1177==11++..111111%%%%%%%%%%%%%%++%%..44::+++.   u   W"%%%""