0
我运行这个脚本从pdf创建一个jpg图像。PHP Imagick()需要很长时间才能执行
$im = new Imagick();
$im->setResolution(300, 300);
$im->readImage($temp_path . $file);
if ($im->getImageColorspace() == \Imagick::COLORSPACE_CMYK) {
$profiles = $im->getImageProfiles('*', false);
// we're only interested if ICC profile(s) exist
$has_icc_profile = (array_search('icc', $profiles) !== false);
// if it doesnt have a CMYK ICC profile, we add one
if ($has_icc_profile === false) {
$icc_cmyk = file_get_contents(dirname(dirname(__FILE__)) . '/USWebUncoated.icc');
$im->profileImage('icc', $icc_cmyk);
unset($icc_cmyk);
}
// then we add an RGB profile
$icc_rgb = file_get_contents(dirname(dirname(__FILE__)) . '/sRGB_v4_ICC_preference.icc');
$im->profileImage('icc', $icc_rgb);
unset($icc_rgb);
}
$im->setImageBackgroundColor('white');
$im = $im->flattenImages();
$im->setImageFormat('jpeg');
$im->thumbnailImage(900, 900, true);
工作正常,但问题是需要很长时间来执行。有一段时间,如果文件有很多细节我得到一个超时从php执行。
我之前使用它没有profileImage()文件,并正在完善,但对CMYK颜色是不正确的。
我该如何做得更好更高效。我使用php5.5.9在linux上运行这个。
谢谢。
我之前尝试和我以前不工作。这是我加载配置文件的颜色 –