PHP Conference Japan 2024

Imagick::profileImage

(PECL imagick 2, PECL imagick 3)

Imagick::profileImage從影像新增或移除設定檔

描述

public Imagick::profileImage(string $name, ?string $profile): bool

從影像新增或移除 ICC、IPTC 或一般設定檔。如果設定檔為 NULL,則會從影像中移除,否則會新增。使用名稱 '*' 和 NULL 的設定檔可從影像中移除所有設定檔。

參數

name

profile

回傳值

成功時回傳 true

錯誤/例外

發生錯誤時會拋出 ImagickException。

新增筆記

使用者貢獻筆記 3 則筆記

7
dadima, gmail
10 年前
如果 profileImage() 看起來沒有作用 — 而且在 CMYK > RGB 轉換期間「色彩反轉」是個徵兆 — 請檢查 ImageMagick 是否有可用的 lcms 委派。
從命令提示字元
convert -list configure | grep DELEGATES

如果在清單中沒有看到 lcms,則 Imagick 不會進行任何色彩設定檔轉換,也不會提供任何關於此的警告。在這種情況下,請安裝 Little CMS 函式庫 ( http://www.littlecms.com/ ) 並重新編譯 ImageMagick。
8
Eero Niemi (eero at eero dot info)
16 年前
如果您需要將 CMYK 格式的影像轉換為 RGB 並想要保留色彩資訊,這可能會有所幫助

<?php
$image
= new Imagick("CMYK_image.jpg"); // 載入影像
$profiles = $image->getImageProfiles('*', false); // 取得設定檔
$has_icc_profile = (array_search('icc', $profiles) !== false); // 如果存在 ICC 設定檔,我們就會感興趣

if ($has_icc_profile === false)
{
// 影像沒有 CMYK ICC 設定檔,我們新增一個
$icc_cmyk = file_get_contents('/path/to/icc/SomeCMYKProfile.icc');
$image->profileImage('icc', $icc_cmyk);
}

// 接著我們需要新增 RGB 設定檔
$icc_rgb = file_get_contents('/path/to/icc/SomeRGBProfile.icc');
$image->profileImage('icc', $icc_rgb);

$image->setImageColorSpace(Imagick::COLORSPACE_RGB);

$image->writeImage("RGB_image.jpg");

?>

可能有更好更優雅的方法來做到這一點,但希望這有所幫助。
0
gavin at softyolk dot com
15 年前
感謝您提供的寶貴資訊。
為了進一步朝正確的方向推進,請
考慮您必須下載設定檔,

而您最有可能的來源是

http://www.color.org/srgbprofiles.xalter



http://www.adobe.com/support/downloads/product.jsp?product=62&platform=Windows

請注意,這些設定檔是免費的,但您必須安裝它們
才能讓它們在您的主機系統上可用。
To Top