0
votes

I'm using PHP Imagick to convert PNG images generated in PhantomJS to TIF CMYK, for print purposes I need a flat Black (cmyk - 0,0,0,100) - the conversion generates blacks like (cmyk - 58,49,44,89).

I'm converting the images using color profile (section of my code below) -> the code is based on Convert image from RGB to CMYK with Imagick

is it possible to force a flat black with Imagick ? do you know any other tools that might help ?

thanks,

if ($has_icc_profile === false) {
    $icc_rgb = file_get_contents( '/srgb_profiles' . '/sRGB.icc');
    $image->profileImage('icc', $icc_rgb);
    unset($icc_rgb);
}
// then we add an CMYK profile
$icc_cmyk = file_get_contents( '/cmyk_profiles'.'/JapanColor2002Newspaper.icc');
$image->profileImage('icc', $icc_cmyk);

UPDATE :

after checking online I think I'm looking for a UCR en.wikipedia.org/wiki/Under_color_removal method for ImageMagick - I found that convert old versions supported under color removal

-undercolor <undercolor factor>x<black-generation factor>
control undercolor removal and black generation on CMYK images.
This option enables you to perform undercolor removal and black generation on CMYK images--      images   to be printed on a four-color printing system. You can con- trol how much cyan, magenta, and yellow to remove from your image and how much black to add to it. The standard undercolor removal is 1.0x1.0. You'll frequently get better results, though, if the percentage of black you add to your image is slightly higher than the percentage of C, M, and Y you remove from it. For example you might try 0.5x0.7. (http://www.chemie.fu-berlin.de/chemnet/use/suppl/imagemagick/www/convert.html) - 

apparently the option is not supported anymore, I'm interested if anyone knows if UCR is the solution I'm looking for and if anyone knows if it's supported or if I'm supposed to use a different method to get the same result.

1
Do you happen to even know of an algorithm that allows you to specify you want 100% black in the RGB->CMYK conversion? What if you want to print white? Are you going to put down 100% black and then lots of negative CMY to counteract it? Or do you only want to use 100% or 0% black? Or maybe only 0%, 33%, 66% and 100% black? I Googled but cannot find such an algorithm... if you can find one, it is probably possible to make ImageMagick do it. - Mark Setchell
Hi, I don't know of alogorithm to do that, thing is that in RGB the black Value is 0,0,0 - I wanted to know if there is a way to force ImageMagick to convert rgb(0,0,0) to cmyk(0,0,0,100) - to avoid the rich black - or if I can use any of ImageMagick functions to replace the black. - nirhere
Are you purely concerend about rgb(0,0,0)? What about rgb(1,1,1)? I am not being picky or argumentative - just trying to understand. - Mark Setchell
for now I'm concerned with rgb(0,0,0) - I have a chart image generated Js > SVG > PNG - with phantomJs. the phantomJs result has a rgb(0,0,0) - I'm interested in a (0,0,0) to cmyk solution. or if possible in a more fuzzy solution - nirhere

1 Answers

0
votes

If you use ImageMagick's convert at the command line like this to generate a grayscale ramp, 1 pixel wide and 256 pixels tall, going from white to black and convert it to CMYK colorspace and then show it as text, you get what you want:

convert -size 1x256 'gradient:rgb(255,255,255)-rgb(0,0,0)' -colorspace cmyk txt:
# ImageMagick pixel enumeration: 1,256,65535,cmyk
0,0: (0%,0%,0%,0%)  #0000000000000000  cmyk(0,0,0,0)
0,1: (0%,0%,0%,0.392157%)  #0000000000000101  cmyk(0,0,0,1)
0,2: (0%,0%,0%,0.784314%)  #0000000000000202  cmyk(0,0,0,2)
0,3: (0%,0%,0%,1.17647%)  #0000000000000303  cmyk(0,0,0,3)
0,4: (0%,0%,0%,1.56863%)  #0000000000000404  cmyk(0,0,0,4)
0,5: (0%,0%,0%,1.96078%)  #0000000000000505  cmyk(0,0,0,5)
0,6: (0%,0%,0%,2.35294%)  #0000000000000606  cmyk(0,0,0,6)
0,7: (0%,0%,0%,2.7451%)  #0000000000000707  cmyk(0,0,0,7)
0,8: (0%,0%,0%,3.13725%)  #0000000000000808  cmyk(0,0,0,8)
0,9: (0%,0%,0%,3.52941%)  #0000000000000909  cmyk(0,0,0,9)
0,10: (0%,0%,0%,3.92157%)  #0000000000000A0A  cmyk(0,0,0,10)
...
...
0,249: (0%,0%,0%,97.6471%)  #000000000000F9F9  cmyk(0,0,0,249)
0,250: (0%,0%,0%,98.0392%)  #000000000000FAFA  cmyk(0,0,0,250)
0,251: (0%,0%,0%,98.4314%)  #000000000000FBFB  cmyk(0,0,0,251)
0,252: (0%,0%,0%,98.8235%)  #000000000000FCFC  cmyk(0,0,0,252)
0,253: (0%,0%,0%,99.2157%)  #000000000000FDFD  cmyk(0,0,0,253)
0,254: (0%,0%,0%,99.6078%)  #000000000000FEFE  cmyk(0,0,0,254)
0,255: (0%,0%,0%,100%)  #000000000000FFFF  cmyk(0,0,0,255)

You must be doing something different - maybe this will help you work it out. I am guessing it is your ICC profiles but you can experiment with the above command.

If you just want to experiment with spot values, you can just have IM translate a single pixel like this:

convert -size 1x1 xc:#000000 -colorspace cmyk txt:
# ImageMagick pixel enumeration: 1,1,65535,cmyk
0,0: (0%,0%,0%,100%)  #000000000000FFFF  cmyk(0,0,0,255)

or maybe more simply like this:

convert -size 1x1 xc:#000000 -depth 8 -colorspace cmyk txt:
# ImageMagick pixel enumeration: 1,1,255,cmyk
0,0: (0,0,0,255)  #000000FF  cmyk(0,0,0,255)

Note the following though:

  1. You must put profiles between input image and output image names on the command line.

  2. If your image has no embedded profile, the first profile you give is applied to the input image and the second to the output image. If your input image does have a profile, the first profile you give is applied to the output image.