11

I'm about to converting RGB color to CMYK for printing purpose. scale of this conversion is Adobe Photoshop ( Image -> Mode -> CMYK color )

I tried 2 solution , but none of them return the right value :

Solution 1 - Using .NET Framework

At first , I followed by these steps

  • Download ICC profiles (windows version) from Adobe

  • Convert the #color to CMYK

  • used System.Windows.Media.Color.FromValues // return Color MSDN

  • string convretedColor = string.Format("#{0:X2}{1:X2}{2:X2}", _color.R, _color.G, _color.B)

here is the result :

  • profile : CoatedFOGRA27.icc

  • Original Color : #2f00ff

  • Converted Color : #3b4996

  • Result of conversion With Adobe Photoshop (same profile) : #3b4996 not even close!

Solution 2 - Using Windows Color System ( WCS )

I also tried the Codo's solution with same procedure

here is the result :

  • Profile : CoatedFOGRA27.icc

  • Original Color : #2f00ff

  • Converted Color : #2032FF

  • Photoshop : #3b4996

JSFiddle for compare

EDIT

According to Codo's Comments, I think, I have some fundamental problems of understanding colors concept !! ( please correct me if I'm wrong )

For any color, we have different color models , RGB , CMYK, ...

RGB shows the combination of (Red Green Blue) to generate color and CMYK as well (Cyan Magenta Yellow * ). the values of these models can easily convert to each-other.

for example :

  • RGB HEX : #2F00FF

  • RGB : 47 - 0 - 255

  • CMYK : 0,816 - 1,000 - 0,000 - 0,000

Almost, all monitors use RGB to shows the colors.the printed color (because of using Ink instead of LED o ...) is totally different from the color that you see on monitor/

For this issue, Image Editors like Photoshop use CMYK **MODE**.In this mode , if you select the RGB color, the editor convert it to color that you see after printing and shows that to screen.this conversion is absolutely depend on color Profiles ( here ICC )

EDIT 2

enter image description here

Community
  • 1
  • 1
Mironline
  • 2,755
  • 7
  • 35
  • 61
  • Which one of all these color values is supposed to be a CMYK value? And why are you trying to convert to CMYK if the target seems to be HTML, which doesn't support CMYK? – Codo Aug 16 '13 at 15:54
  • @Codo, The story is : end-user selects the RGB color, I'm using HEX to pass the color to server. In post-back I want to show `converted-to-CMYK` color that he has selected! In Photoshop, when you set the `Mode > CMYK` and select and fill with `#2f00ff`, the result is `#3b4996`. – Mironline Aug 16 '13 at 17:10
  • 1
    I don't understand it (and I don't have Photoshop installed). What are your color values (#xxxxxx) supposed to be? They all look like RGB values to me. Where is the CMYK value? – Codo Aug 16 '13 at 17:51
  • @Codo Please re-check the question [ edit segment ] – Mironline Aug 16 '13 at 18:33
  • 1
    I still don't understand what you're trying to achieve. Can you better describe what you're doing, what you expect to get and what you effectively get. And I would expect that you need both a RGB to CMYK and a CMYK to RGB conversion. But I don't see not CMYK to RGB conversion. – Codo Aug 16 '13 at 19:08
  • Dear @Codo , thank you for your patient, please check the edit2. – Mironline Aug 16 '13 at 21:05

3 Answers3

8

Let me try to help you sort it all out:

1) RGB is a format to describe a color value. i.e.: 255,0,0 for red.

2) HSV is another format to describe a color value. i.e.: 0,100,100 for red

Those two are the only ones that will give you the digitally accurate color,
you can think of them as digital representation of the color or it's real DNA and thanks god the monitor is able to present them - exactly for what they are.

Let's move on:

3) Lab is another format to describe a color value.

54,81,70 for red RGB which is (255,0,0) however..
54,81,70 can also apply to a different RGB.. (254,0,0)

why is that? because Lab format is designed to approximate human vision.
and for the human eye there is no difference between (255,0,0) and (254,0,0)
well.. not really accurate to say that for the human eye..
more accurate to say the model which is being used to get the Lab color which intends to..

4) CYMK is designed to tell the printer what mixes of Cyan, Yellow and Magenta to press to the paper and K (key or black) for how much dark to press into that mix.

So 0%,100%,100%,0% will give us the mixture for red..
and 0%,50%,50%,0% will give us pink.

Let's move on:

Your effort is to adjust the RGB which seen in the monitor to the CMYK of the printer.
God knows why you want to do that when it's been fully automatic and handled by the driver for years..
But I assume you have your reasons, So let's continue,
Each printer has a slightly different CMYK values to mix to get to that specific red..

And this is where ICC profiles come into action..
They give a standard for RED in example by providing table for (1) the original RGB-RED and (2) the CMYK red in a specific printer.

So converting from RGB(Red) to CMYK(red) according to an ICC profile is logical to wish for.

But if you try to convert back - you will notice that the CMYK for RED according to a specific profile can have multiple digital RED values..

This is because the digital color resolution is much more accurate than what comes out to a printed paper, another way to look at it is to say that a specific printer ICC could have been built upon Lab.

Now I know.. I know.. you probably already knew most of if not all of it.
(I wrote it just to be sure we both on same page in the book.)

So, when you say "none of them return the right value" (Assuming them = the conversions) what exactly do you mean?! All seems right to me, as In fact they do return the right value - for printing purposes.

G.Y
  • 6,042
  • 2
  • 37
  • 54
  • Dear G.V : WOW!! I'm try to develop a website for printing services. client select the `RGB-RED` from color-picker as paper background.he expect to deliver the same `RED` as he selected.for this issue,we post the `RGB-RED` color to server and convert that to `CMYK` with specific ICC (according to my solutions) and post-it-back to client and replace with his `RGB-RED` _and alert him to notice new color!_ NOW the problem: the `Project Owner` starts this procedure and click the `PrintSCR` and do it again with `Photoshop` to compare the converted colors!unfortunately the results are not equal. – Mironline Aug 26 '13 at 00:22
  • 1
    ok much better now :) so when your client choose that paper background color he select RGB and you want to convert it to a cmyk according to a specific ICC profile. all great.. just one thing.. Who said photoshop's interpretation of the CMYK is the correct one? we already established a CMYK red can have many RGB red included in it. So who exactly is to say that the one photoshop picked to display is the best one? I.e: In photoshop color picker select rgb(186,72,190) -> and printScr, now open paint.Net and sample that color in its color picker and p.net shows rgb(186,71,190).. PS simply wrong. – G.Y Aug 26 '13 at 02:13
  • Convincing `Product Owners` that your engine works better than `Porsche` !!! impossible ;) I found [Adobe Color Management](http://www.adobe.com/support/downloads/detail.jsp?ftpID=3618). I'm working on it.... – Mironline Aug 26 '13 at 08:56
  • Exciting :P Adobe finally understood it has glitches in its color management module beyond the fact that there is a natural delta in conversions due to difference in color-ranges.. So it trying to establish its module as the industry standard for conversions.. Well, it will solve your problem alright :) – G.Y Aug 26 '13 at 10:22
  • 1
    No and most definitely and absolutely no! RGB is *not* a digitally absolute or accurate color, quite the opposite. You know *nothing* about the actual red an R255 G0 B0 triplet represents only that it's usually supposed to be *some kind* of a red. An RGB triplet only has any meaning when using together with a color profile that describes what color space you're actually referring to. – Gábor Sep 23 '14 at 16:42
  • As to the OP's question: forget Photoshop, it doesn't have a say in this business. If you're working with a specific press machine and you have the actual and accurate color profile for the exact printing process you use (including technology, paper stock, everything else, don't forget that profiles have to be re-created regularly), then you might get away using this color profile for your conversions but most likely not. [...] – Gábor Sep 23 '14 at 16:47
  • [...] RGB cannot be converted reliably to CMYK and back in the context you describe. If the end user has to provide a specific color to be printed, then either let them provide it in CMYK (which is still not precise enough due to differences in technology and printing material) or, to be really precise, only use Pantone spot colors. Anything else will just misguide you clients, unfortunately. – Gábor Sep 23 '14 at 16:48
4

May be this (untested) snippet helps a bit - it uses the the .NET api for ImageMagick.

MagickReadSettings settings = new MagickReadSettings();
settings.ColorSpace = ColorSpace.CMYK;
using (MagickImage image = new MagickImage())
{
  image.AddProfile(ColorProfile.CMYK);
  image.Read("image_rgb.tiff", settings);
  image.Write("image_cmyk.tiff");
}

If you can use the commandline this will also do the job:

convert image_rgb.tiff -profile "RGB.icc" -profile "CMYK.icc" image_cmyk.tiff
Jost
  • 1,549
  • 12
  • 18
  • This solution just saved my life! 2 hours 'til the development deadline, I was beginning to worry. I spent days trying to convert RGB to CMYK in C#, then I found this solution, and it worked within a matter of minutes. Thank you! – todbott May 24 '19 at 07:40
3

As I see the theory…

The gamut of CMYK by itself is slightly smaller than RGB, so the difference after straight RGB->CMYK conversion will be easy visible. In order to compensate that diff Color Profiles are used. Color Profile inside is actually a set of color transforms which allows to enlarge the gamut. In this case image source is just a source for these transforms.

CMYK is almost always used with Color Profiles (I mean correct use cases) otherwise color loss will be significant.

In Photoshop try to convert here: Edit -> Convert to Profile. The main difference from your way - you can choose destination CMYK profile and color managment engine including Microsoft ICM, which could give you different results.

Here is a good article about CMYK: http://www.northlight-images.co.uk/article_pages/colour_management/cmyk_for_photographers.html

As for programming...

Maybe it will be easier to use some specialized image processing SDK. Color Management is a basic feature of any of them and should be available even for free.

If you need to estimate how your RGB color will be actually printed you need to use feature called “soft proofing”. This is RGB -> CMYK (with printer profile) -> RGB conversion. In Photoshop you can check it here: View -> Proof Color. You can do the same thing with SDKs.

Eugene
  • 3,335
  • 3
  • 36
  • 44