【发布时间】:2015-04-24 12:23:48
【问题描述】:
我很难尝试将图像从 Adobe RGB 转换为 sRGB 配置文件,现在我开始认为我可能根本无法在主机上分配或转换颜色配置文件。
ImageMagick 6.8.9-6 Q16 x86_64 2014-08-15
class_exists("Imagick") = true
在这里,我尝试将配置文件分配给使用 IM 创建的图像,即使这样也不起作用.. 这里有什么问题?
try {
$image = new Imagick();
$image->newImage(100, 100, new ImagickPixel('red'));
$image->setImageFormat('jpg');
$image->setImageCompression(Imagick::COMPRESSION_JPEG);
$image->setImageCompressionQuality(60);
// TRY 1
// $image->setImageColorspace(Imagick::COLORSPACE_SRGB);
// TRY 2
$profile_path = "sRGB_IEC61966-2-1_black_scaled.icc";
$profile = file_get_contents($profile_path);
$image->profileImage("icc", $profile);
$image->setImageColorspace(Imagick::COLORSPACE_SRGB);
} catch(Exception $e) {
echo 'Exception caught: ', $e->getMessage(), "\n";
}
header("Content-Type: image/jpg");
echo $image->getImageBlob();
编辑这是我尝试使用 Adobe RGB 颜色空间的现有图像:
try {
$profile_path = "sRGB_IEC61966-2-1_black_scaled.icc";
$image = new Imagick();
$image->readImage("original-small.jpg");
// TRY 1 > keeps the same Adobe RGB profile
// $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);
// TRY 2 > strips all EXIF data + profile but does NOT assign new profile
// $image->stripImage();
// $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);
// TRY 3 > keeps the same Adobe RGB profile
// $profile = file_get_contents($profile_path);
// $image->profileImage("icc", $profile);
// $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);
// TRY 4 > strips all EXIF data + profile but does NOT assign new profile
// $image->stripImage();
// $profile = file_get_contents($profile_path);
// $image->profileImage("icc", $profile);
// $image->transformImageColorspace(Imagick::COLORSPACE_SRGB);
} catch(Exception $e) {
echo 'Exception caught: ', $e->getMessage(), "\n";
}
header("Content-Type: image/jpg");
echo $image->getImageBlob();
【问题讨论】:
标签: imagick color-profile