我有一张带有嵌入式颜色配置文件的JPEG图片。一些 Web 浏览器显示带有应用配置文件的图像,有些则不显示。如何将颜色配置文件应用于图像和删除配置文件,以便所有浏览器都以相同的方式显示图像。
我尝试通过图像魔术扩展来解决问题,但图像在不同的浏览器中仍然显示不同:
function add_color_profiles($source_path, $target_path){
$all_exts = get_loaded_extensions();
if(!in_array('imagick',$all_exts))
return true;
$im1 = new Imagick($source_path);
$im2 = new Imagick($target_path);
$profiles = $im1->getImageProfiles();
if(!$profiles)
return true;
foreach($profiles as $name => $profile){
$im2->setImageProfile($name,$profile);
}
$im2->writeImage ($target_path);
return true;
}
将配置文件应用于图像(将图像色彩空间转换为 RGB):
$im->setImageColorspace(IMagick::COLORSPACE_RGB);
从输出文件中去除配置文件信息:
$im->profileImage('*', NULL);
剥离所有配置文件的图像,exif(注释GPS数据等):
$im->stripImage();