ImageCms
模組¶
ImageCms
模組使用 Kevin Cazabon 的 PyCMS 函式庫為基礎,提供使用 LittleCMS2 色彩管理引擎的色彩描述檔管理支援。
- class PIL.ImageCms.ImageCmsProfile(profile: str | SupportsRead[bytes] | CmsProfile)[原始碼]¶
- __init__(profile: str | SupportsRead[bytes] | CmsProfile) None [原始碼]¶
- 參數:
profile – 代表檔案名稱的字串、包含描述檔的檔案類物件或低階描述檔物件
- class PIL.ImageCms.ImageCmsTransform(input: ~PIL.ImageCms.ImageCmsProfile, output: ~PIL.ImageCms.ImageCmsProfile, input_mode: str, output_mode: str, intent: ~PIL.ImageCms.Intent = Intent.PERCEPTUAL, proof: ~PIL.ImageCms.ImageCmsProfile | None = None, proof_intent: ~PIL.ImageCms.Intent = Intent.ABSOLUTE_COLORIMETRIC, flags: ~PIL.ImageCms.Flags = <Flags.NONE: 0>)[原始碼]¶
基底類別:
ImagePointHandler
轉換。這可以與程序式 API 或標準
point()
方法搭配使用。會在
output.info['icc_profile']
中傳回輸出描述檔。
常數¶
- 類別 PIL.ImageCms.Intent(value, names=<未提供>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[原始碼]¶
基底類別:
IntEnum
- PERCEPTUAL = 0¶
- RELATIVE_COLORIMETRIC = 1¶
- SATURATION = 2¶
- ABSOLUTE_COLORIMETRIC = 3¶
- 類別 PIL.ImageCms.Direction(value, names=<未提供>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[原始碼]¶
基底類別:
IntEnum
- INPUT = 0¶
- OUTPUT = 1¶
- PROOF = 2¶
- 類別 PIL.ImageCms.Flags(value, names=<未提供>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[原始碼]¶
基底類別:
IntFlag
旗標和文件取自
lcms2.h
。- NONE = 0¶
- NOCACHE = 64¶
抑制 1 像素快取
- NOOPTIMIZE = 256¶
抑制最佳化
- NULLTRANSFORM = 512¶
無論如何不進行轉換
- GAMUTCHECK = 4096¶
超出色域警報
- SOFTPROOFING = 16384¶
執行軟打樣
- BLACKPOINTCOMPENSATION = 8192¶
- NOWHITEONWHITEFIXUP = 4¶
不要修復雜點
- HIGHRESPRECALC = 1024¶
使用更多記憶體以提供更好的精確度
- LOWRESPRECALC = 2048¶
使用較少記憶體以最小化資源
- USE_8BITS_DEVICELINK = 8¶
建立 8 位元裝置連結
- GUESSDEVICECLASS = 32¶
猜測裝置類別 (用於
transform2devicelink
)
- KEEP_SEQUENCE = 128¶
保留裝置連結建立的設定檔順序
- FORCE_CLUT = 2¶
強制 CLUT 最佳化
- CLUT_POST_LINEARIZATION = 1¶
如果可能,建立後線性化表格
- CLUT_PRE_LINEARIZATION = 16¶
如果可能,建立前線性化表格
- NONEGATIVES = 32768¶
防止浮點轉換中的負數
- COPY_ALPHA = 67108864¶
Alpha 通道會在
cmsDoTransform()
中複製。
- NODEFAULTRESOURCEDEF = 16777216¶
函式¶
- PIL.ImageCms.applyTransform(im: Image, transform: ImageCmsTransform, inPlace: bool = False) Image | None [原始碼]¶
(pyCMS) 將轉換套用到指定的影像。
如果
im.mode != transform.input_mode
,則會引發PyCMSError
。如果
inPlace
為True
且transform.input_mode != transform.output_mode
,則會引發PyCMSError
。如果
im.mode
、transform.input_mode
或transform.output_mode
不受 pyCMSdll 或您用於轉換的設定檔支援,則會引發PyCMSError
。如果在套用轉換時發生錯誤,則會引發
PyCMSError
。此函式將預先計算的轉換 (來自 ImageCms.buildTransform() 或 ImageCms.buildTransformFromOpenProfiles()) 套用到影像。轉換可以多次用於多個影像,如果多次執行相同的轉換,則可以節省大量的計算時間。
如果您想要就地修改 im 而不是接收新影像作為回傳值,請將
inPlace
設定為True
。只有在transform.input_mode
和transform.output_mode
相同時,才能執行此操作,因為我們無法就地變更模式 (某些模式的緩衝區大小不同)。預設行為是傳回具有相同維度的新Image
物件,模式為transform.output_mode
。- 參數:
- 傳回:
根據
inPlace
的值,傳回None
或新的Image
物件。設定檔將會傳回在影像的info['icc_profile']
中。- 引發:
- PIL.ImageCms.buildProofTransform(inputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, outputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, proofProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, inMode: str, outMode: str, renderingIntent: ~PIL.ImageCms.Intent = Intent.PERCEPTUAL, proofRenderingIntent: ~PIL.ImageCms.Intent = Intent.ABSOLUTE_COLORIMETRIC, flags: ~PIL.ImageCms.Flags = <Flags.SOFTPROOFING: 16384>) ImageCmsTransform [原始碼]¶
(pyCMS) 建構一個 ICC 轉換,將
inputProfile
對應到outputProfile
,但嘗試模擬在proofProfile
裝置上獲得的結果。如果指定的輸入、輸出或校樣設定檔不是有效的檔名,則會引發
PyCMSError
。如果在建立轉換期間發生錯誤,則會引發
PyCMSError
。如果
inMode
或outMode
不是outputProfile
(或 pyCMS) 支援的模式,則會引發PyCMSError
。此函式會建構並傳回從
inputProfile
到outputProfile
的 ICC 轉換,但嘗試模擬使用renderingIntent
和proofRenderingIntent
來決定如何處理色域外的顏色,以模擬在proofProfile
裝置上獲得的結果。這稱為「軟打樣」。它僅適用於將inMode
中的影像轉換為 outMode 色彩格式 (PIL 模式,例如「RGB」、「RGBA」、「CMYK」等) 的影像。產生的轉換物件的使用方式與 ImageCms.buildTransform() 完全相同。
軟打樣通常用於在使用輸出裝置時,可以很好地了解最終列印/顯示的影像在
proofProfile
裝置上的外觀,當使用輸出裝置來判斷色彩更快、更容易時。一般來說,這表示輸出裝置是監視器或染料昇華印表機 (等等),而模擬的裝置是更昂貴、複雜或耗時的裝置 (因此很難為了判斷色彩而製作實際列印)。軟打樣的基本功能是調整輸出裝置上的色彩,使其與模擬裝置的色彩相符。但是,當模擬裝置的色域遠大於輸出裝置時,您可能會得到邊際效益。
- 參數:
inputProfile – 字串,作為您想要用於此轉換的 ICC 輸入描述檔的有效檔案路徑,或是一個描述檔物件。
outputProfile – 字串,作為您想要用於此轉換的 ICC 輸出(通常是監視器)描述檔的有效檔案路徑,或是一個描述檔物件。
proofProfile – 字串,作為您想要用於此轉換的 ICC 校樣描述檔的有效檔案路徑,或是一個描述檔物件。
inMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
outMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
renderingIntent –
整數 (0-3),指定您想要用於輸入 -> 校樣(模擬)轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
proofRenderingIntent –
整數 (0-3),指定您想要用於校樣 -> 輸出轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
flags – 整數 (0-…),指定額外的旗標。
- 傳回:
CmsTransform 類別物件。
- 引發:
- PIL.ImageCms.buildProofTransformFromOpenProfiles(inputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, outputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, proofProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, inMode: str, outMode: str, renderingIntent: ~PIL.ImageCms.Intent = Intent.PERCEPTUAL, proofRenderingIntent: ~PIL.ImageCms.Intent = Intent.ABSOLUTE_COLORIMETRIC, flags: ~PIL.ImageCms.Flags = <Flags.SOFTPROOFING: 16384>) ImageCmsTransform ¶
(pyCMS) 建構一個 ICC 轉換,將
inputProfile
對應到outputProfile
,但嘗試模擬在proofProfile
裝置上獲得的結果。如果指定的輸入、輸出或校樣設定檔不是有效的檔名,則會引發
PyCMSError
。如果在建立轉換期間發生錯誤,則會引發
PyCMSError
。如果
inMode
或outMode
不是outputProfile
(或 pyCMS) 支援的模式,則會引發PyCMSError
。此函式會建構並傳回從
inputProfile
到outputProfile
的 ICC 轉換,但嘗試模擬使用renderingIntent
和proofRenderingIntent
來決定如何處理色域外的顏色,以模擬在proofProfile
裝置上獲得的結果。這稱為「軟打樣」。它僅適用於將inMode
中的影像轉換為 outMode 色彩格式 (PIL 模式,例如「RGB」、「RGBA」、「CMYK」等) 的影像。產生的轉換物件的使用方式與 ImageCms.buildTransform() 完全相同。
軟打樣通常用於在使用輸出裝置時,可以很好地了解最終列印/顯示的影像在
proofProfile
裝置上的外觀,當使用輸出裝置來判斷色彩更快、更容易時。一般來說,這表示輸出裝置是監視器或染料昇華印表機 (等等),而模擬的裝置是更昂貴、複雜或耗時的裝置 (因此很難為了判斷色彩而製作實際列印)。軟打樣的基本功能是調整輸出裝置上的色彩,使其與模擬裝置的色彩相符。但是,當模擬裝置的色域遠大於輸出裝置時,您可能會得到邊際效益。
- 參數:
inputProfile – 字串,作為您想要用於此轉換的 ICC 輸入描述檔的有效檔案路徑,或是一個描述檔物件。
outputProfile – 字串,作為您想要用於此轉換的 ICC 輸出(通常是監視器)描述檔的有效檔案路徑,或是一個描述檔物件。
proofProfile – 字串,作為您想要用於此轉換的 ICC 校樣描述檔的有效檔案路徑,或是一個描述檔物件。
inMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
outMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
renderingIntent –
整數 (0-3),指定您想要用於輸入 -> 校樣(模擬)轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
proofRenderingIntent –
整數 (0-3),指定您想要用於校樣 -> 輸出轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
flags – 整數 (0-…),指定額外的旗標。
- 傳回:
CmsTransform 類別物件。
- 引發:
- PIL.ImageCms.buildTransform(inputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, outputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, inMode: str, outMode: str, renderingIntent: ~PIL.ImageCms.Intent = Intent.PERCEPTUAL, flags: ~PIL.ImageCms.Flags = <Flags.NONE: 0>) ImageCmsTransform [原始碼]¶
(pyCMS) 建立從
inputProfile
對應到outputProfile
的 ICC 轉換。使用 applyTransform 將轉換套用到指定的影像。如果指定的輸入或輸出描述檔不是有效的檔案名稱,將會引發
PyCMSError
。如果在建立轉換期間發生錯誤,將會引發PyCMSError
。如果
inMode
或outMode
不是outputProfile
(或 pyCMS) 支援的模式,則會引發PyCMSError
。此函式會建立並傳回從
inputProfile
到outputProfile
的 ICC 轉換,並使用renderingIntent
來決定如何處理色域外的色彩。它只會將inMode
中的影像轉換為outMode
色彩格式(PIL 模式,例如 “RGB”、“RGBA”、“CMYK” 等)的影像。建立轉換是 ImageCms.profileToProfile() 中相當一部分的負擔,因此如果您計劃使用相同的輸入/輸出設定轉換多個影像,這可以節省您的時間。一旦您擁有轉換物件,它就可以與 ImageCms.applyProfile() 一起使用來轉換影像,而無需重新計算轉換的查找表。
pyCMS 傳回類別物件而非直接傳回轉換的句柄的原因是,它需要追蹤轉換所適用的 PIL 輸入/輸出模式。這些屬性會儲存在物件的
inMode
和outMode
屬性中(如果您真的想,可以手動覆寫這些屬性,但我不知道有任何時間會用到,甚至會起作用)。- 參數:
inputProfile – 字串,作為您想要用於此轉換的 ICC 輸入描述檔的有效檔案路徑,或是一個描述檔物件。
outputProfile – 字串,作為您想要用於此轉換的 ICC 輸出描述檔的有效檔案路徑,或是一個描述檔物件。
inMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
outMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
renderingIntent –
整數 (0-3),指定您想要用於轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
flags – 整數 (0-…),指定額外的旗標。
- 傳回:
CmsTransform 類別物件。
- 引發:
- PIL.ImageCms.buildTransformFromOpenProfiles(inputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, outputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, inMode: str, outMode: str, renderingIntent: ~PIL.ImageCms.Intent = Intent.PERCEPTUAL, flags: ~PIL.ImageCms.Flags = <Flags.NONE: 0>) ImageCmsTransform ¶
(pyCMS) 建立從
inputProfile
對應到outputProfile
的 ICC 轉換。使用 applyTransform 將轉換套用到指定的影像。如果指定的輸入或輸出描述檔不是有效的檔案名稱,將會引發
PyCMSError
。如果在建立轉換期間發生錯誤,將會引發PyCMSError
。如果
inMode
或outMode
不是outputProfile
(或 pyCMS) 支援的模式,則會引發PyCMSError
。此函式會建立並傳回從
inputProfile
到outputProfile
的 ICC 轉換,並使用renderingIntent
來決定如何處理色域外的色彩。它只會將inMode
中的影像轉換為outMode
色彩格式(PIL 模式,例如 “RGB”、“RGBA”、“CMYK” 等)的影像。建立轉換是 ImageCms.profileToProfile() 中相當一部分的負擔,因此如果您計劃使用相同的輸入/輸出設定轉換多個影像,這可以節省您的時間。一旦您擁有轉換物件,它就可以與 ImageCms.applyProfile() 一起使用來轉換影像,而無需重新計算轉換的查找表。
pyCMS 傳回類別物件而非直接傳回轉換的句柄的原因是,它需要追蹤轉換所適用的 PIL 輸入/輸出模式。這些屬性會儲存在物件的
inMode
和outMode
屬性中(如果您真的想,可以手動覆寫這些屬性,但我不知道有任何時間會用到,甚至會起作用)。- 參數:
inputProfile – 字串,作為您想要用於此轉換的 ICC 輸入描述檔的有效檔案路徑,或是一個描述檔物件。
outputProfile – 字串,作為您想要用於此轉換的 ICC 輸出描述檔的有效檔案路徑,或是一個描述檔物件。
inMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
outMode – 字串,作為適當描述檔也支援的有效 PIL 模式(例如 “RGB”、“RGBA”、“CMYK” 等)。
renderingIntent –
整數 (0-3),指定您想要用於轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
flags – 整數 (0-…),指定額外的旗標。
- 傳回:
CmsTransform 類別物件。
- 引發:
- PIL.ImageCms.createProfile(colorSpace: Literal['LAB', 'XYZ', 'sRGB'], colorTemp: SupportsFloat = 0) CmsProfile [原始碼]¶
(pyCMS) 建立一個描述檔。
如果 colorSpace 不在
["LAB", "XYZ", "sRGB"]
中,則會引發PyCMSError
。如果使用 LAB 且
colorTemp
不是正整數,則會引發PyCMSError
。如果在建立描述檔時發生錯誤,將會拋出
PyCMSError
異常。使用此函式可以即時建立常用的描述檔,而無需提供磁碟上的描述檔並知道其路徑。它會傳回一個正常的 CmsProfile 物件,可以傳遞給 ImageCms.buildTransformFromOpenProfiles() 以建立要套用至影像的轉換。
- 參數:
colorSpace – 字串,您想要建立的描述檔的色彩空間。目前僅支援 “LAB”、“XYZ” 和 “sRGB”。
colorTemp – 正數,表示描述檔的白點,單位為開爾文度(例如 5000、6500、9600 等)。如果省略,則預設為 D50 照明體 (5000k)。colorTemp 僅適用於 LAB 描述檔,對於 XYZ 和 sRGB 會被忽略。
- 傳回:
CmsProfile 類別物件。
- 引發:
- PIL.ImageCms.getDefaultIntent(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) int [原始碼]¶
(pyCMS) 取得指定描述檔的預設意圖名稱。
如果
profile
不是有效的 CmsProfile 物件或描述檔的檔案名稱,則會拋出PyCMSError
異常。如果在嘗試取得預設意圖時發生錯誤,則會拋出
PyCMSError
異常。使用此函式來判斷此描述檔的預設(且通常為最佳化)渲染意圖。大多數描述檔都支援多種渲染意圖,但主要用於一種轉換類型。如果您希望使用與傳回值不同的意圖,請先使用 ImageCms.isIntentSupported() 來驗證它是否可以運作。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
整數 0-3,指定此描述檔的預設渲染意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
- 請參閱 pyCMS 文件,以了解有關渲染意圖及其作用的詳細資訊。
它們的作用。
- 引發:
- PIL.ImageCms.getOpenProfile(profileFilename: str | SupportsRead[bytes] | CmsProfile) ImageCmsProfile [原始碼]¶
(pyCMS) 開啟一個 ICC 描述檔。
PyCMSProfile 物件可以傳回給 pyCMS,以用於建立轉換等操作(如 ImageCms.buildTransformFromOpenProfiles() 中)。
如果
profileFilename
不是有效的 ICC 描述檔檔案名稱,則會拋出PyCMSError
異常。- 參數:
profileFilename – 字串,作為要開啟的 ICC 描述檔的有效檔案路徑,或是一個類檔案物件。
- 傳回:
CmsProfile 類別物件。
- 引發:
- PIL.ImageCms.getProfileCopyright(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) str [原始碼]¶
(pyCMS) 取得指定描述檔的版權資訊。
如果
profile
不是有效的 CmsProfile 物件或描述檔的檔案名稱,則會拋出PyCMSError
異常。如果在嘗試取得版權標籤時發生錯誤,則會拋出
PyCMSError
異常。使用此函式來取得儲存在描述檔版權標籤中的資訊。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
一個字串,包含儲存在 ICC 標籤中的內部描述檔資訊。
- 引發:
- PIL.ImageCms.getProfileDescription(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) str [原始碼]¶
(pyCMS) 取得指定描述檔的描述。
如果
profile
不是有效的 CmsProfile 物件或描述檔的檔案名稱,則會拋出PyCMSError
異常。如果在嘗試取得描述標籤時發生錯誤,則會拋出
PyCMSError
異常。使用此函式來取得儲存在描述檔描述標籤中的資訊。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
一個字串,包含儲存在 ICC 標籤中的內部描述檔資訊。
- 引發:
- PIL.ImageCms.getProfileInfo(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) str [原始碼]¶
(pyCMS) 取得指定描述檔的內部產品資訊。
如果
profile
不是有效的 CmsProfile 物件或描述檔的檔案名稱,則會拋出PyCMSError
異常。如果在嘗試取得資訊標籤時發生錯誤,則會拋出
PyCMSError
異常。使用此函式來取得儲存在描述檔資訊標籤中的資訊。這通常包含有關描述檔的詳細資訊,以及建立方式(由建立者提供)。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
一個字串,包含儲存在 ICC 標籤中的內部描述檔資訊。
- 引發:
- PIL.ImageCms.getProfileManufacturer(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) str [原始碼]¶
(pyCMS) 取得指定描述檔的製造商。
如果
profile
不是有效的 CmsProfile 物件或描述檔的檔案名稱,則會拋出PyCMSError
異常。如果在嘗試取得製造商標籤時發生錯誤,則會拋出
PyCMSError
異常。使用此函式來取得儲存在描述檔製造商標籤中的資訊。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
一個字串,包含儲存在 ICC 標籤中的內部描述檔資訊。
- 引發:
- PIL.ImageCms.getProfileModel(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) str [原始碼]¶
(pyCMS) 取得指定配置文件的模型。
如果
profile
不是有效的 CmsProfile 物件或描述檔的檔案名稱,則會拋出PyCMSError
異常。如果在嘗試取得模型標籤時發生錯誤,會引發
PyCMSError
錯誤。使用此函式取得儲存在配置文件的模型標籤中的資訊。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
一個字串,包含儲存在 ICC 標籤中的內部描述檔資訊。
- 引發:
- PIL.ImageCms.getProfileName(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile) str [原始碼]¶
(pyCMS) 取得指定配置文件的內部產品名稱。
如果
profile
不是有效的 CmsProfile 物件或配置文件的檔案名稱,會引發PyCMSError
錯誤。如果在嘗試取得名稱標籤時發生錯誤,會引發PyCMSError
錯誤。使用此函式取得配置文件的內部名稱(儲存在配置文件本身的 ICC 標籤中),通常是最初建立配置文件時使用的名稱。有時此標籤也包含建立者提供的其他資訊。
- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
- 傳回:
一個字串,包含儲存在 ICC 標籤中的配置文件內部名稱。
- 引發:
- PIL.ImageCms.get_display_profile(handle: SupportsInt | None = None) ImageCmsProfile | None [原始碼]¶
(實驗性) 獲取目前顯示裝置的配置文件。
- 傳回:
如果配置文件未知,則為
None
。
- PIL.ImageCms.isIntentSupported(profile: str | SupportsRead[bytes] | CmsProfile | ImageCmsProfile, intent: Intent, direction: Direction) Literal[-1, 1] [原始碼]¶
(pyCMS) 檢查是否支援給定的意圖。
使用此函式驗證是否可以將您想要的
intent
與profile
一起使用,並且profile
可以如您所願用作輸入/輸出/校樣配置文件。某些配置文件是專為一個「方向」建立的,不能用於其他方向。某些配置文件只能用於特定的渲染意圖,因此最好先驗證這一點(使用此函式),再嘗試使用它們建立轉換,或捕獲如果它們不支援您選擇的模式時可能發生的
PyCMSError
錯誤。- 參數:
profile – 有效的 CmsProfile 物件,或是 ICC 描述檔的檔案名稱字串。
intent –
指定您希望在此配置文件中使用的渲染意圖的整數 (0-3)。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
- 請參閱 pyCMS 文件,以了解有關渲染意圖及其作用的詳細資訊。
它們的作用。
direction –
指定配置文件是用於輸入、輸出還是校樣的整數。
INPUT = 0(或使用 ImageCms.Direction.INPUT) OUTPUT = 1(或使用 ImageCms.Direction.OUTPUT) PROOF = 2(或使用 ImageCms.Direction.PROOF)
- 傳回:
如果支援意圖/方向,則為 1,否則為 -1。
- 引發:
- PIL.ImageCms.profileToProfile(im: ~PIL.Image.Image, inputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, outputProfile: str | ~PIL._typing.SupportsRead[bytes] | ~PIL.ImageCms.core.CmsProfile | ~PIL.ImageCms.ImageCmsProfile, renderingIntent: ~PIL.ImageCms.Intent = Intent.PERCEPTUAL, outputMode: str | None = None, inPlace: bool = False, flags: ~PIL.ImageCms.Flags = <Flags.NONE: 0>) Image | None [原始碼]¶
(pyCMS) 將 ICC 轉換套用至指定的圖像,從
inputProfile
映射到outputProfile
。如果指定的輸入或輸出描述檔不是有效的檔案名稱,將會引發
PyCMSError
。如果inPlace
為True
且outputMode != im.mode
,將會引發PyCMSError
。如果在應用描述檔期間發生錯誤,將會引發PyCMSError
。如果outputMode
不是outputProfile
(或 pyCMS)支援的模式,將會引發PyCMSError
。此函式將 ICC 轉換應用於 im,從
inputProfile
的色彩空間轉換至outputProfile
的色彩空間,並使用指定的渲染意圖來決定如何處理超出色域的色彩。outputMode
可用於指定使用這些描述檔進行色彩模式轉換,但指定的描述檔必須能夠處理該模式。也就是說,如果使用描述檔將 im 從 RGB 轉換為 CMYK,輸入描述檔必須能夠處理 RGB 資料,而輸出描述檔必須能夠處理 CMYK 資料。- 參數:
im – 開啟的
Image
物件(即 Image.new(…) 或 Image.open(…) 等)。inputProfile – 字串,作為您希望用於此影像的 ICC 輸入描述檔的有效檔案路徑,或一個描述檔物件。
outputProfile – 字串,作為您希望用於此影像的 ICC 輸出描述檔的有效檔案路徑,或一個描述檔物件。
renderingIntent –
整數 (0-3),指定您想要用於轉換的彩現意圖。
ImageCms.Intent.PERCEPTUAL = 0 (預設) ImageCms.Intent.RELATIVE_COLORIMETRIC = 1 ImageCms.Intent.SATURATION = 2 ImageCms.Intent.ABSOLUTE_COLORIMETRIC = 3
請參閱 pyCMS 文件,以了解關於彩現意圖及其作用的詳細資訊。
outputMode – 輸出影像的有效 PIL 模式(即「RGB」、「CMYK」等)。注意:如果「就地」渲染影像,outputMode 必須與輸入模式相同,或完全省略。如果省略,outputMode 將與輸入影像的模式 (im.mode) 相同。
inPlace – 布林值。如果
True
,則會就地修改原始影像,並傳回None
。如果False
(預設),則會傳回已套用轉換的新Image
物件。flags – 整數 (0-…),指定額外的旗標。
- 傳回:
None 或新的
Image
物件,取決於inPlace
的值。- 引發:
CmsProfile¶
ICC 色彩描述檔會包裝在類別 CmsProfile
的實例中。規格 ICC.1:2010 包含更多關於 ICC 描述檔中數值意義的資訊。
為方便起見,所有 XYZ 值也會以 xyY 值形式給出(因此可以輕鬆地在色度圖中顯示,例如)。
- class PIL.ImageCms.core.CmsProfile¶
- creation_date: datetime.datetime | None¶
此描述檔首次建立的日期和時間(請參閱 ICC.1:2010 的 7.2.1)。
- device_class: str¶
識別描述檔類別的 4 字元字串。為
scnr
、mntr
、prtr
、link
、spac
、abst
、nmcl
其中之一(詳細資訊請參閱 ICC.1:2010 的 7.2.5)。
- header_manufacturer: str¶
識別裝置製造商的 4 字元字串(以空格填補),該字串應與 www.color.org 上的 ICC 簽名登錄的適當章節中包含的簽名相符(請參閱 ICC.1:2010 的 7.2.12)。
- header_model: str¶
識別裝置型號的 4 字元字串(以空格填補),該字串應與 www.color.org 上的 ICC 簽名登錄的適當章節中包含的簽名相符(請參閱 ICC.1:2010 的 7.2.13)。
- rendering_intent: int¶
當將此描述檔與另一個描述檔合併使用時的渲染意圖(通常在執行時覆寫,但此處提供給 DeviceLink 和嵌入式來源描述檔,請參閱 ICC.1:2010 的 7.2.15 節)。
以下之一:
ImageCms.Intent.ABSOLUTE_COLORIMETRIC
、ImageCms.Intent.PERCEPTUAL
、ImageCms.Intent.RELATIVE_COLORIMETRIC
和ImageCms.Intent.SATURATION
。
- profile_id: bytes¶
用於識別描述檔的 16 個位元組序列(透過特別建構的 MD5 總和),如果尚未計算描述檔 ID,則為 16 個二進位零(請參閱 ICC.1:2010 的 7.2.18 節)。
- red_colorant: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
用於矩陣/TRC 轉換的矩陣中的第一欄(請參閱 ICC.1:2010 的 9.2.44 節)。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- green_colorant: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
用於矩陣/TRC 轉換的矩陣中的第二欄(請參閱 ICC.1:2010 的 9.2.30 節)。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- blue_colorant: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
用於矩陣/TRC 轉換的矩陣中的第三欄(請參閱 ICC.1:2010 的 9.2.4 節)。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- 亮度: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
發光裝置的絕對亮度,單位為燭光每平方公尺,如 Y 通道所述 (請參閱 ICC.1:2010 的 9.2.32)。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- 色度: tuple[tuple[float, float, float], tuple[float, float, float], tuple[float, float, float]] | None¶
所使用的磷光體/著色劑色度資料集 (紅色、綠色和藍色通道,請參閱 ICC.1:2010 的 9.2.16)。
如果有,則值的格式為
((x, y, Y), (x, y, Y), (x, y, Y))
。
- 色彩適應: tuple[tuple[tuple[float, float, float], tuple[float, float, float], tuple[float, float, float]], tuple[tuple[float, float, float], tuple[float, float, float], tuple[float, float, float]]] | None¶
色彩適應矩陣將使用實際照明條件測量並相對於實際採用白色的顏色,轉換為相對於 PCS 採用白色的顏色,並從實際採用的白色色度完全適應為 PCS 採用的白色色度 (請參閱 ICC.1:2010 的 9.2.15)。
會在一個 2 元組中回傳兩個 3 元組的浮點數,一個在 (X, Y, Z) 空間中,另一個在 (x, y, Y) 空間中。
- 著色劑輸出表: list[str]¶
此標籤通過唯一名稱和一組 PCSLAB 值來識別設定檔中使用的著色劑 (僅適用於 DeviceLink 設定檔,請參閱 ICC.1:2010 的 9.2.19)。
- colorimetric_intent: str | None¶
4 個字元的字串(以空白填充),用於識別使用色彩度意圖轉換產生的 PCS 色度圖像狀態(詳情請參閱 ICC.1:2010 的 9.2.20 節)。
- perceptual_rendering_intent_gamut: str | None¶
4 個字元的字串(以空白填充),用於識別(一個)標準參考媒介色域(詳情請參閱 ICC.1:2010 的 9.2.37 節)。
- saturation_rendering_intent_gamut: str | None¶
4 個字元的字串(以空白填充),用於識別(一個)標準參考媒介色域(詳情請參閱 ICC.1:2010 的 9.2.37 節)。
- media_black_point: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
此標籤指定媒介黑點,用於產生絕對色度。
此標籤在 ICC 3.2 中可用,但在第 4 版中已移除。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- red_primary: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
RGB 原色紅色 (1, 0, 0) 的 XYZ 轉換。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- green_primary: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
RGB 原色綠色 (0, 1, 0) 的 XYZ 轉換。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- blue_primary: tuple[tuple[float, float, float], tuple[float, float, float]] | None¶
RGB 原色藍色 (0, 0, 1) 的 XYZ 轉換。
如果可用,則值格式為
((X, Y, Z), (x, y, Y))
。
- clut: dict[int, tuple[bool, bool, bool]] | None¶
傳回 CLUT 模型所有支援的意圖和方向的字典。
字典的索引依據意圖 (
ImageCms.Intent.ABSOLUTE_COLORIMETRIC
、ImageCms.Intent.PERCEPTUAL
、ImageCms.Intent.RELATIVE_COLORIMETRIC
和ImageCms.Intent.SATURATION
)。值為 3 元組,索引依據方向 (
ImageCms.Direction.INPUT
、ImageCms.Direction.OUTPUT
、ImageCms.Direction.PROOF
)。元組的元素為布林值。如果值為
True
,表示該意圖支援該方向。
- intent_supported: dict[int, tuple[bool, bool, bool]] | None¶
傳回所有支援的意圖和方向的字典。
字典的索引依據意圖 (
ImageCms.Intent.ABSOLUTE_COLORIMETRIC
、ImageCms.Intent.PERCEPTUAL
、ImageCms.Intent.RELATIVE_COLORIMETRIC
和ImageCms.Intent.SATURATION
)。值為 3 元組,索引依據方向 (
ImageCms.Direction.INPUT
、ImageCms.Direction.OUTPUT
、ImageCms.Direction.PROOF
)。元組的元素為布林值。如果值為
True
,表示該意圖支援該方向。
在此類別上定義了一個函式
- is_intent_supported(intent: int, direction: int, /)¶
傳回給定方向是否支援該意圖。
請注意,您也可以使用
intent_supported
取得所有意圖和方向的此資訊。- 參數:
intent –
ImageCms.Intent.ABSOLUTE_COLORIMETRIC
、ImageCms.Intent.PERCEPTUAL
、ImageCms.Intent.RELATIVE_COLORIMETRIC
和ImageCms.Intent.SATURATION
其中之一。direction –
ImageCms.Direction.INPUT
、ImageCms.Direction.OUTPUT
和ImageCms.Direction.PROOF
其中之一
- 傳回:
如果支援該意圖和方向,則為布林值。