将CMYK颜色值和RGB颜色相互转换的PHP代码

function hex2rgb($hex) {$color = str_replace('#','',$hex);$rgb = array('r' => hexdec(substr($color,0,2)),'g' => hexdec(substr($color,2,2)),'b' => hexdec(substr($color,4,2)));return $rgb;} // www.jbxue.comfunction rgb2cmyk($var1,$g=0,$b=0) {if (is_array($var1)) {$r = $var1['r'];$g = $var1['g'];$b = $var1['b'];} else {$r=$var1;}$cyan = 255 - $r;$magenta = 255 - $g;$yellow = 255 - $b;$black = min($cyan, $magenta, $yellow);$cyan = @(($cyan - $black) / (255 - $black)) * 255;$magenta = @(($magenta - $black) / (255 - $black)) * 255;$yellow = @(($yellow - $black) / (255 - $black)) * 255;return array('c' => $cyan / 255,'m' => $magenta / 255,'y' => $yellow / 255,'k' => $black / 255);}$color=rgb2cmyk(hex2rgb('#FF0000'));

php技术将CMYK颜色值和RGB颜色相互转换的PHP代码,转载需保留来源!

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。