*ec@sddlmZdZdZddlmZddlZeZdZdZ dZ d Z dZ dZ dZidd 6dd 6dCd 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd6d d!6d"d#6d$d%6d&d'6d(d)6ZdZx0ejD]"ZeeereeBZqqWd*dDd+YZd,ejfd-YZdd.Zd/efd0YZedddd1Zd2Zedd3Zee ed#d4ZeZ eZ!dd5Z"dd6Z#d7Z$d8Z%d9Z&d:Z'd;Z(e)d<krdd=lm*Z*e+e,xpe-e.D]_Z/e+d>d?e+d@e/y)dAe/dUdBe0kre+e0nWq=e1k rq=Xq=WndS(Ei(tprint_functions/ pyCMS a Python / PIL interface to the littleCMS ICC Color Management System Copyright (C) 2002-2003 Kevin Cazabon kevin@cazabon.com http://www.cazabon.com pyCMS home page: http://www.cazabon.com/pyCMS littleCMS home page: http://www.littlecms.com (littleCMS is Copyright (C) 1998-2001 Marti Maria) Originally released under LGPL. Graciously donated to PIL in March 2009, for distribution under the standard PIL license The pyCMS.py module provides a "clean" interface between Python/PIL and pyCMSdll, taking care of some of the more complex handling of the direct pyCMSdll functions, as well as error-checking and making sure that all relevant data is kept together. While it is possible to call pyCMSdll functions directly, it's not highly recommended. Version History: 0.1.0 pil mod March 10, 2009 Renamed display profile to proof profile. The proof profile is the profile of the device that is being simulated, not the profile of the device which is actually used to display/print the final simulation (that'd be the output profile) - also see LCMSAPI.txt input colorspace -> using 'renderingIntent' -> proof colorspace -> using 'proofRenderingIntent' -> output colorspace Added LCMS FLAGS support. Added FLAGS["SOFTPROOFING"] as default flag for buildProofTransform (otherwise the proof profile/intent would be ignored). 0.1.0 pil March 2009 - added to PIL, as PIL.ImageCms 0.0.2 alpha Jan 6, 2002 Added try/except statements arount type() checks of potential CObjects... Python won't let you use type() on them, and raises a TypeError (stupid, if you ask me!) Added buildProofTransformFromOpenProfiles() function. Additional fixes in DLL, see DLL code for details. 0.0.1 alpha first public release, Dec. 26, 2002 Known to-do list with current version (of Python interface, not pyCMSdll): none s 0.1.0 pil(tImageNiiiit MATRIXINPUTt MATRIXOUTPUTt MATRIXONLYitNOWHITEONWHITEFIXUPitNOPRELINEARIZATIONi tGUESSDEVICECLASSi@tNOTCACHEit NOTPRECALCit NULLTRANSFORMitHIGHRESPRECALCit LOWRESPRECALCi tWHITEBLACKCOMPENSATIONtBLACKPOINTCOMPENSATIONit GAMUTCHECKi@t SOFTPROOFINGit PRESERVEBLACKitNODEFAULTRESOURCEDEFcCs |d@d>S(Nii((tn((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytzst GRIDPOINTStImageCmsProfilecBseZdZddZRS(cCsjtj|r+|jtj||n;t|drY|jtj|jn |j|dS(Ntread(Rt isStringTypet_settcoret profile_openthasattrtprofile_frombytesR(tselftprofile((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyt__init__s cCsI||_||_|r3|j|_|j|_nd|_d|_dS(N(Rtfilenamet product_namet product_infotNone(RRR!((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyRs    N(t__name__t __module__R R$R(((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyRs tImageCmsTransformcBs;eZededdZdZddZdZRS(ic Cs|dkr6tj|j|j|||||_n0tj|j|j|j||||||_||_|_||_|_ dS(N( R$RtbuildTransformRt transformtbuildProofTransformt input_modet inputModet output_modet outputMode( RtinputtoutputR+R-tintenttprooft proof_intenttflags((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyR s   cCs |j|S(N(tapply(Rtim((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytpointscCsY|j|dkr4tj|j|jd}n|jj|jj |jj }|S(N( tloadR$RtnewR-tsizeR)R5R6tid(RR6timOuttresult((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyR5s   !cCsP|j|j|jkr+tdn|jj|jj|jj}|S(Ns mode mismatch(R8tmodeR-t ValueErrorR)R5R6R;(RR6R=((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytapply_in_places  !N( R%R&tINTENT_PERCEPTUALR$tINTENT_ABSOLUTE_COLORIMETRICR R7R5R@(((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyR's   cCsddl}|jdkrjddlm}t||jrRtj|d}qtj|pad}n+y tj }Wnt k rdSX|}t |S(Nitwin32(tImageWinii( tsystplatformtPILRDt isinstancetHDCRtget_display_profile_win32t _imagingcmstget_display_profiletAttributeErrorR$R(thandleRERDRtget((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyRLs    t PyCMSErrorcBseZRS((R%R&(((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyRPsc CsO|dkr|j}nt|t sEd|ko?dkn rTtdnt|t sd|ko{tkn rtdtnyt|tst|}nt|tst|}nt|||j||d|}|r|j|d}n|j |}Wn(t t t fk rJ} t| nX|S(Niis2renderingIntent must be an integer between 0 and 3s)flags must be an integer between 0 and %sR4( R$R>RHtintRPt _MAX_FLAGRR'R@R5tIOErrort TypeErrorR?( R6t inputProfilet outputProfiletrenderingIntentR.tinPlaceR4R)R<tv((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytprofileToProfiles(  --  cCs=yt|SWn(tttfk r8}t|nXdS(N(RRSRTR?RP(tprofileFilenameRY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytgetOpenProfileBsc Cst|t s-d|ko'dkn r<tdnt|t sid|koctkn r|tdtny\t|tst|}nt|tst|}nt|||||d|SWn(tttfk r}t|nXdS(Niis2renderingIntent must be an integer between 0 and 3s)flags must be an integer between 0 and %sR4( RHRQRPRRRR'RSRTR?(RURVtinModetoutModeRWR4RY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyR(}s-- c Cs(t|t s-d|ko'dkn r<tdnt|t sid|koctkn r|tdtny}t|tst|}nt|tst|}nt|tst|}nt||||||||SWn(tttfk r#}t|nXdS(Niis2renderingIntent must be an integer between 0 and 3s)flags must be an integer between 0 and %s( RHRQRPRRRR'RSRTR?( RURVt proofProfileR]R^RWtproofRenderingIntentR4RY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyR*s--#cCs[y/|r|j|d}n|j|}Wn%ttfk rV}t|nX|S(N(R@R$R5RTR?RP(R6R)RXR<RY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytapplyTransform s  cCs|dkrtd|n|dkrrt|trMt|d}nt|tsrtd|qrnytj||SWn%ttfk r}t|nXdS(NtLABtXYZtsRGBs>Color space not supported for on-the-fly profile creation (%s)g?s<Color temperature must be a positive integer, "%s" not valid(RbRcRd(RPRHtfloatRQRt createProfileRTR?(t colorSpacet colorTempRY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyRf1s  cCsby0t|ts!t|}n|jjdSWn+ttttfk r]}t|nXdS(Ns ( RHRRR"RMRSRTR?RP(RRY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytgetProfileNameRs cCs_y-t|ts!t|}n|jdSWn+ttttfk rZ}t|nXdS(Ns (RHRR#RMRSRTR?RP(RRY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytgetProfileInfons cCs^y,t|ts!t|}n|jjSWn+ttttfk rY}t|nXdS(N( RHRRtrendering_intentRMRSRTR?RP(RRY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytgetDefaultIntents cCsqy?t|ts!t|}n|jj||r:dSdSWn+ttttfk rl}t|nXdS(Nii( RHRRtis_intent_supportedRMRSRTR?RP(RR1t directionRY((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytisIntentSupportedscCs/ddl}ttj|jjdtjfS(Nii(REtVERSIONRtlittlecms_versiontversiontsplitR(RE((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pytversionss t__main__(tImageCmst=iPs%ssdoc = ImageCms.%s.__doc__tpyCMSi((2t __future__Rt DESCRIPTIONRpRGRRKRRAtINTENT_RELATIVE_COLORIMETRICtINTENT_SATURATIONRBtDIRECTION_INPUTtDIRECTION_OUTPUTtDIRECTION_PROOFtFLAGSRRtvaluestflagRHRQRtImagePointHandlerR'R$RLt ExceptionRPRZR\R(R*tbuildTransformFromOpenProfilest#buildProofTransformFromOpenProfilesRaRfRiRjRlRoRtR%Rvtprintt__doc__tdirRxtftdocRM(((s2/usr/lib64/python2.7/site-packages/PIL/ImageCms.pyts<   , 1* ;W& $ !  $ +