将 CMYK PDF 转换为 RGB JPG 全黑

Convert CMYK PDF to RGB JPG goes all black

我有这个位是几年前设置的并且一直运行良好:

$imagick = new Imagick();
// Sets the image resolution
$imagick->setResolution(300, 300);
// Reads image from PDF
$imagick->readImage($pdf_here);
// apply CMYK profile before converting to RGB
$icc_cmyk = file_get_contents('../../profiles/CoatedGRACoL2006.icc');
$imagick->profileImage('icc', $icc_cmyk);
// convert to RGB using Adobe icc profile
$icc_rgb = file_get_contents('../../profiles/AdobeRGB1998.icc');
$imagick->profileImage('icc', $icc_rgb);
$imagick->setImageColorspace(Imagick::COLORSPACE_SRGB);
// crop to trim size
$imagick->cropImage(1050, 600, 37.5, 37.5);
// Writes an image
$imagick->writeImage($jpg_here);

但现在它决定不再工作了。 我正在生成一个使用 PMS 颜色的 CMYK PDF,如下所示:

它的转换一直很好,但现在它决定转换成这样:

我曾尝试上传不同的较新的 RGB 和 CMYK 配置文件,但没有成功,要么没有任何不同,要么反转了颜色。我对本可以改变的事情完全不知所措。我根本没有改变这个文件。我一直在更新大约 10 年前编码为 MySQL 查询的站点的其他方面,并且需要使用准备好的语句更新到 mySQLi。

正如@fmw42 所说,setImageColorspace 没有正常工作。 我最终完全删除了配置文件,只使用了 setColorspace。像这样:

// create Imagick object
$imagick = new Imagick();
// Sets the image resolution
$imagick->setResolution(300, 300);
// set color space
$imagick->setColorspace(Imagick::COLORSPACE_SRGB);
// Reads image from PDF
$imagick->readImage($pdf_here);
// crop to trim size
$imagick->cropImage(1050, 600, 37.5, 37.5);
// Writes an image
$imagick->writeImage($jpg_here);