使用PHP中的ICC配置文件将RGB转换为CMYK

I am currently building an online APP which allows users to pick a color for text from a usual javascript color picker. I want to convert the returned value to CMYK and I know there is not one simple run-of-the-mill method to achieve this, given there are ICC profiles and all that.

I still want to achieve a relatively useful conversion the way "most" users know from Photoshop. The profiles I want to use are "AdobeRGB" for the RGB colorspace, and "Coated Fogra39" for the CMYK colorspace.

What I want to know is, if there is any method to convert single color values from one colorspace to the other, by utilizing these two ICC profiles (which I have downloaded). There are methods to convert entire images with ImageMagick, but I am dying trying to find a way to just calculate from one color value to the other. I am also inclined to use other means of achieving this goal if there are any ideas out there.

Thanks.

You could use Imagick::setImageColorSpace

Here's a tutorial

Also i must warn you cmyk profile is for printing not for screening they will be differences and you can't calculate the same as rgb ( rgb misses the black thing ) an example for black ( everyone know's this color ) RGB Black : 0, 0, 0, CMYK Black: 100%; But they 100% key doesn't work the same on some printers you only need 100% on others like the one that i use a roland sp 540i i make a combination of colors to produce different types of black based on what i need because 100%key will not produce the black that everyone knows and you can test it even in photoshop / corel draw to see a difference if your screen helps u.

Other examples:

  • Registration Black | C100 M100 Y100 K100
  • Neutral Rich Black (also known as Rich Black) | C40 M30 Y30 K100
  • Flat Black | C0 M0 Y0 K100 - This black is just made up of 100% of the black channel, with no other ink in the mix. Also known as Standard black.
  • Designer Black | C70 M50 Y30 K100 Pantone® Process Black | Spot-Color/’K100′ : This black is available as Pantone® Process Black C (coated), U, (Uncoated) and M (Matt).
  • Cool Black (also known as Black Bump) | C50 M0 Y0 K100 : This is the general-mix, but this black can also be comprised [typically] of between 20%-80% cyan.
  • Golden Black | C0 M0 Y60 K100 : This is the general-mix, but this black can also be comprised [typically] of between 20%-80% yellow.
  • Warm Black | C0 M60 Y0 K100 : This is the general-mix, but this black can also be comprised [typically] of between 20%-80% magenta.

So you see CMYK is very different from rgb space because is used for printing and that means you will have trouble if you don't know how it works.

Update: ICC Profiles are for monitors not for printing ..

You can try to create a Photoshop image that consists of a series of gradients that emulate a subset of all RGB colors and then save this as a CMYK (say uncompressed TIFF so you can use the image like a lookup table). Read the color values and based on those create a set of equations that can extrapolate the destination CMYK from a lookup in this image, although that is a lot of effort, tried once and abandoned, somewhat complex... Or, give the user a reduced set of combinations and store those in a table, like all the #000 -- #fff combinations, if that is acceptable for you.

RGB -- CMYK conversion is far from simple, that's why Adobe progs cost money...