📜  PHP | imagick profileImage()函数

📅  最后修改于: 2022-05-13 01:56:52.607000             🧑  作者: Mango

PHP | imagick profileImage()函数

Imagick::profileImage()函数是PHP中的一个内置函数,用于从图像中添加或删除配置文件。如果配置文件为 NULL,则将其从图像中删除,否则会添加。
关于 ICC 图像配置文件:在色彩管理中,ICC 配置文件是一组数据,根据国际色彩联盟 (ICC) 颁布的标准,表征色彩输入或输出设备或色彩空间。颜色空间是指颜色的特定组织。
句法:

bool Imagick::profileImage( $name, $profile )

参数:该函数接受上面提到的两个参数,如下所述:

  • $name:此参数保存图像配置文件的名称。
  • $profile:此参数保存配置文件的内容。

返回值:此函数在成功时返回 true。
下面的程序说明了PHP中的 Imagick::profileImage()函数:
程序:

php
getImageProfiles('*', false);
 
// Checking for any icc profile added to the image
$has_icc_profile = (array_search('icc', $profiles) !== false);
 
 
if ($has_icc_profile === false) {
 
    // If image does not have ICC profile, then add one
    $icc = file_get_contents('D:\\Merawamp\\www\\New\\to\\icc\\CMYK.icc');
     
    // Use Imagick::profileimage() function to add the
    // profile to an image the profile added to the
    // image is the file D:\\Merawamp\\www\\New\\to\\icc\\CMYK.icc
    $trip1 = $image->profileImage('icc', $icc);
}
 
// If method runs successfully it returns true
if($trip1 == true) {
    echo "Profile added to image successfully";
}
 
?>


输出: