Мне так тяжело пытаться преобразовать изображения из профиля Adobe RGB в профиль sRGB, что теперь я начинаю думать, что, возможно, я вообще не могу назначать или преобразовывать цветовые профили на своем хосте.
ImageMagick 6.8.9-6 Q16 x86_64 15 августа 2014 г.
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();