Image from RGB To Cmyk in php

北慕城南 提交于 2019-12-13 05:12:14

问题


I've some problem with php and imagick, i want to convert some image from rgb system to cmyk, but i've only black/or non background nothing else.

    $icc_cmyk = file_get_contents('USWebUncoated.icc');
    $img->profileImage('icc', $icc_cmyk);
    $img->setImageColorspace(12);
    if ($php_vs < 5.3) {
        //ADJUST GAMMA BY 20% for 5.2.x
        $img->levelImage(0, 2.0, $range['quantumRangeString']);
    } else {
        //php 5.3 hack FOR INVERTED COLORS
        $img->negateImage(false, Imagick::CHANNEL_ALL);
    }
    $img->stripImage();

//$img->setImageColorspace(Imagick::COLORSPACE_CMYK);
$img->writeImage('cmyk.png');

回答1:


All right I've some resolve but i don't know it's working, if someone can taste it i will be very greatfull :)

        $img->setImageColorspace(13);
    $icc_rgb = file_get_contents('AdobeRGB1998.icc');
    $img->profileImage('icc', $icc_rgb);
    unset($icc_rgb);
    $icc_cmyk = file_get_contents('USWebUncoated.icc');
    $img->profileImage('icc', $icc_cmyk);
    $img->setImageColorspace(12);
    unset($icc_cmyk);
    $img->setimagecolorspace(Imagick::COLORSPACE_CMYK);
    $img->stripImage();
    $img->writeImage('cmyk.png');



回答2:


Use this working RGB to CMYK Image with Php

$icc_cmyk = file_get_contents('images/CoatedFOGRA27.icc');// Your Cmyk ICC Profile
$img->profileImage('icc', $icc_cmyk);
$img->transformimagecolorspace(Imagick::COLORSPACE_CMYK);
$img->writeImage('cmyk.jpg');// Save as jpg or jpeg`


来源:https://stackoverflow.com/questions/17932567/image-from-rgb-to-cmyk-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!