thanks a lot for help.
i find a code and i added it converting Algorithm.
problem how i will create a new image with this CMYK value.
Because imagecolorallocate is not allowed.
Code is:
<?
$imgname = "imagecolor.jpg";
$image = @imagecreatefromjpeg($imgname);
$imagehw = GetImageSize($imgname);
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
print("Width : $imagewidth : Height : $imageheight <BR>");
for ($row = 0 ; $row < $imageheight ; $row++)
{
for ($col = 0 ; $col < $imagewidth ; $col++)
{
$rgb = ImageColorAt($image, $col, $row);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
/* RGB —> CMY */
$C = 1 - ( $r / 255 );
$M = 1 - ( $g / 255 );
$Y = 1 - ( $b / 255 );
/* CMY —> CMYK */
$var_K = 1;
if ( $C < $var_K ) $var_K = $C;
if ( $M < $var_K ) $var_K = $M;
if ( $Y < $var_K ) $var_K = $Y;
$C = ( $C - $var_K ) / ( 1 - $var_K );
$M = ( $M - $var_K ) / ( 1 - $var_K );
$Y = ( $Y - $var_K ) / ( 1 - $var_K );
$K = $var_K;
print("$row : $col -- $C : $M : $K :$K<BR>");
}
}
?>
And output is:
Width : 426 : Height : 254
0 : 0 -- 0 : 0.30588235294118 : 0 :0
0 : 1 -- 0 : 0.34509803921569 : 0 :0
0 : 2 -- 0 : 0.30801687763713 : 0.070588235294118 :0.070588235294118
0 : 3 -- 0 : 0.25957446808511 : 0.07843137254902 :0.07843137254902
0 : 4 -- 0 : 0.23504273504274 : 0.082352941176471 :0.082352941176471
0 : 5 -- 0 : 0.23788546255507 : 0.10980392156863 :0.10980392156863
0 : 6 -- 0 : 0.25217391304348 : 0.098039215686274 :0.098039215686274
..................