2

Is there a place where I can get the formula which photoshop uses to convert rgb to cmyk? I know there are formulas on the web, but photoshop does not use this formula. It converts the collors different.

Can someone tell me the photoshop formula?

Thanks!

Van Coding
  • 24,244
  • 24
  • 88
  • 132
  • 1
    1) Pick a programming language. SO isn't the place for abstract algorithms 2) MUST it be the exact algorithm PS uses, or can it be a working one for RGB-CMYK? If it must be the exact one, then you're never going to get a valid answer because only the PS team knows and they're not giving that info out. –  Feb 07 '11 at 15:42
  • No it must be the same result. That's the most inportant thing. – Van Coding Feb 07 '11 at 15:54
  • There are many different ways color transforms can generally be programmed, let alone within PhotoShop itself. Where is the area of PhotoShop's color tranform behavior that your trying to reproduce? e.g. in the color picker UI or after appying a new icc profile to a document. – jeffrbauer Jun 30 '12 at 00:36

3 Answers3

5

Most likely, Photoshop uses a color profile for converting RGB to CMYK.

If you want to do the same with a .NET language on Windows, then there's an API for it:

float[] colorValues = new float[4];
colorValues[0] = c / 255f;
colorValues[1] = m / 255f;
colorValues[2] = y / 255f;
colorValues[3] = k / 255f;

System.Windows.Media.Color color = Color.FromValues(colorValues,
    new Uri(@"C:\Users\me\Documents\ISOcoated_v2_300_eci.icc"));
System.Drawing.Color rgbColor = System.Drawing.Color.FromArgb(color.R, color.G, color.B);

Note that two different Color classes from two different namespaces are used. And you probably need to add the PresentationCore DLL as a reference.

In this particular case, the ISO Coated v2 300% (ECI) profile is used. It can be downloaded from the downloads section of eci.org. It's part of a bigger ZIP file containing several profiles.

If you need to convert a complete image from CMYK to RGB, there are special classes in the same namespace that use a color profile as well.

There's a nice little online app for testing the CMYK color conversion with a color profile.

Codo
  • 75,595
  • 17
  • 168
  • 206
  • Hi Codo, thanks for your great piece of code. I understand that this is for going from CYMK to RGB. Could you add another bit where we can convert from RGB to CYMK (the other way around)? Kind regards – Bruno Mar 08 '11 at 16:36
1

They are many different ICC Color Profiles for storing color as CMYK and RGB. There is no one end all be all encoding for color. There is RGB, sRGB, Adobe RGB, U.S. Web Coated (SWOP) v2, GRACol, etc.

As a print provider I'd ask what your end goal is. We can talk a bit about Photoshop scripting if you are looking to work with color objects in Adobe Javascript, but if this has to do with design I would lend this caution: The RGB color space provides a wider color gamut (more colors), many photoshop effects are only available while working in RGB, and the RGB filesize is smaller (only storing 3 channels RGB, instead of 4 CMY & K).

If you save a document as CMYK when it goes to the printer device the printer hardware reinterprets the colors anyhow. So it does not benefit you to work in CMYK most of the time.

Kevin Scharnhorst
  • 721
  • 1
  • 7
  • 14
0

I do use PhotoShop, but a google search tells me that this varies by the devices you are using, and is controlled in Edit > Color Settings (Shift+Ctrl+K).

brian_d
  • 11,190
  • 5
  • 47
  • 72