This project has moved. For the latest updates, please go here.


Apr 10, 2014 at 1:16 PM
I have looked at several threads here regarding CMYK to RGB conversion. I've also modeled my code after the samples. Neither of these routines places an icc profile in the jpeg file. I'm using version x86.
    //Attempt 1
    using (MagickImage image = new MagickImage(args[0]))
        image.ColorSpace = ColorSpace.sRGB;

    //Attempt 2
    using (MagickImage image = new MagickImage(args[0]))
        image.AddProfile(new ColorProfile("sRGB_v4_ICC_preference.icc"));
        image.ColorSpace = ColorSpace.sRGB;
Please help me understand what I'm doing wrong.

Apr 10, 2014 at 1:43 PM
Do you want to perform a CMYK to RGB conversion or do you want to add your profile to the output image? Does your source image contain a color profile? Can you add a link to your input image?
Apr 10, 2014 at 4:52 PM
I want to convert CMYK to RGB and embed an icc profile so the colors match. I don't believe my source image has a color profile. Image Here's the direct link

This is what identify.exe returns on it.
D:\Apps\ImageMagick-6.8.8-Q16>identify -verbose 00000003.jpg
Image: 00000003.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 675x286+0+0
  Resolution: 179x179
  Print size: 3.77095x1.59777
  Units: PixelsPerInch
  Type: ColorSeparation
  Endianess: Undefined
  Colorspace: CMYK
  Depth: 8-bit
  Channel depth:
    cyan: 8-bit
    magenta: 8-bit
    yellow: 8-bit
    black: 8-bit
  Channel statistics:
      min: 0 (0)
      max: 255 (1)
      mean: 44.982 (0.1764)
      standard deviation: 54.7177 (0.214579)
      kurtosis: 1.22171
      skewness: 1.306
      min: 0 (0)
      max: 255 (1)
      mean: 63.3404 (0.248394)
      standard deviation: 73.9775 (0.290108)
      kurtosis: 0.786581
      skewness: 1.296
      min: 0 (0)
      max: 255 (1)
      mean: 57.5256 (0.22559)
      standard deviation: 77.7452 (0.304883)
      kurtosis: 0.980444
      skewness: 1.50539
      min: 0 (0)
      max: 255 (1)
      mean: 26.7778 (0.105011)
      standard deviation: 58.3135 (0.22868)
      kurtosis: 7.24378
      skewness: 2.83538
  Image statistics:
      min: 0 (0)
      max: 255 (1)
      mean: 48.1564 (0.188849)
      standard deviation: 66.9169 (0.262419)
      kurtosis: 2.52627
      skewness: 1.81497
  Total ink density: 330.98%
  Rendering intent: Perceptual
  Gamma: 0.454545
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: cmyk(255,255,255,0)
  Border color: cmyk(223,223,223,0)
  Matte color: cmyk(189,189,189,0)
  Transparent color: cmyk(0,0,0,0)
  Interlace: JPEG
  Intensity: Undefined
  Compose: Over
  Page geometry: 675x286+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 93
  Orientation: TopLeft
    date:create: 2014-04-09T13:15:52-05:00
    date:modify: 2014-04-02T16:06:23-05:00
    exif:BitsPerSample: 8, 8, 8, 8
    exif:ColorSpace: 65535
    exif:Compression: 6
    exif:DateTime: 2014:03:24 14:37:47
    exif:ExifImageLength: 286
    exif:ExifImageWidth: 675
    exif:ExifOffset: 232
    exif:ExifVersion: 48, 50, 50, 49
    exif:ImageLength: 1074
    exif:ImageWidth: 2531
    exif:JPEGInterchangeFormat: 382
    exif:JPEGInterchangeFormatLength: 5027
    exif:Orientation: 1
    exif:PhotometricInterpretation: 5
    exif:ResolutionUnit: 2
    exif:SamplesPerPixel: 4
    exif:Software: Adobe Photoshop CS6 (Windows)
    exif:XResolution: 1790000/10000
    exif:YResolution: 1790000/10000
    jpeg:colorspace: 4
    jpeg:sampling-factor: 1x1,1x1,1x1,1x1
    signature: 2c16abe5ce37547da68a619f286b31eb4e186c1cff36ec35e5369918e11d374b
    Profile-8bim: 7494 bytes
    Profile-exif: 5415 bytes
    Profile-iptc: 15 bytes
      City[1,90]: 0x00000000: 254700                                        -%
    Profile-xmp: 3222 bytes
    filename: 00000003.jpg
    verbose: true
  Tainted: False
  Filesize: 125KB
  Number pixels: 193K
  Pixels per second: 32.18MB
  User time: 0.016u
  Elapsed time: 0:01.005
  Version: ImageMagick 6.8.8-10 Q16 x64 2014-03-25
Apr 10, 2014 at 6:38 PM
There will be no color conversion if the original image does not contain an image profile. I have updated the documentation to explain this better. You should do the following:
using (MagickImage image = new MagickImage("meat.jpg"))
  image.AddProfile(ColorProfile.USWebCoatedSWOP); // Or another CMYK profile
  image.ColorSpace = ColorSpace.sRGB;
Apr 11, 2014 at 1:03 PM
Thanks Dirk. I will try that to see if it works. It's just a bit confusing because ImageMagick/GraphicsMagick doesn't require an image to have a profile to correct the color using the convert command. I just do convert <file.jpg> -profile sRGB.icc <outfile.jpg> and it produces the expected result. Maybe under the hood convert.exe is doing what you propose.

Apr 11, 2014 at 1:15 PM
The colors are closer but they do not match the original. I assume that's because it's mapping USWebCoatedSWOP to SRGB. I'm not sure what convert.exe is doing it but it is working perfectly. Is it possible to have an implementation in your code that works like convert.exe?
Apr 11, 2014 at 1:36 PM
Can you also add a link to the result you are getting from convert? I am not getting the correct result on the command line when I don't specify the CMYK profile.
Apr 11, 2014 at 1:59 PM
Apr 11, 2014 at 2:41 PM
Edited Apr 11, 2014 at 2:41 PM
ImageMagick and GraphicsMagick produce different results so you should really use convert instead of gm.

Your output image is still CMYK and the colors are negated in Windows photo viewer:
C:\Test\jpg>identify i.jpg
i.jpg JPEG 675x286 675x286+0+0 8-bit CMYK 185KB 0.000u 0:00.003
Apr 11, 2014 at 4:44 PM
My mistake. GM converts it properly, IM does not as you have shown however the colors are fine when opened with a program that respects the color profile such as Windows Paint in Windows 8.1. I guess I'm stuck now that IM doesn't translate the colors properly and IM.Net works just like IM. Thanks for your help. Sorry for the run-around.

BTW - Below is GM's convert, which is the image linked a couple threads above.
D:\Apps\GraphicsMagick-1.3.19-Q16>gm identify -verbose i3.jpg
Image: i3.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Geometry: 675x286
  Class: DirectClass
  Type: true color
  Depth: 8 bits-per-pixel component
  Channel Depths:
    Red:      8 bits
    Green:    8 bits
    Blue:     8 bits
  Channel Statistics:
      Minimum:                     0.00 (0.0000)
      Maximum:                 65535.00 (1.0000)
      Mean:                    47978.79 (0.7321)
      Standard Deviation:      18462.24 (0.2817)
      Minimum:                     0.00 (0.0000)
      Maximum:                 65535.00 (1.0000)
      Mean:                    43794.90 (0.6683)
      Standard Deviation:      21085.24 (0.3217)
      Minimum:                     0.00 (0.0000)
      Maximum:                 65535.00 (1.0000)
      Mean:                    45090.56 (0.6880)
      Standard Deviation:      21685.88 (0.3309)
  Resolution: 72x72 pixels/inch
  Filesize: 54.8K
  Interlace: No
  Orientation: TopLeft
  Background Color: white
  Border Color: #DFDFDF
  Matte Color: #BDBDBD
  Page geometry: 675x286+0+0
  Compose: Over
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  JPEG-Quality: 75
  JPEG-Colorspace: 2
  JPEG-Colorspace-Name: RGB
  JPEG-Sampling-factors: 2x2,1x1,1x1
  Signature: 2c6e584c92d1a9fa4fa30b814624500c27f9e89258db86a1ba50930aa9d0b75c
  Profile-iptc: 7494 bytes
  0x00000000: 254700                                        -%

  Profile-EXIF: 5415 bytes
    Image Width: 2531
    Image Length: 1074
    Bits Per Sample: 8
    Photometric Interpretation: 5
    Orientation: 1
    Samples Per Pixel: 4
    X Resolution: 1790000/10000
    Y Resolution: 1790000/10000
    Resolution Unit: 2
    Software: Adobe Photoshop CS6 (Windows)
    Date Time: 2014:03:24 14:37:47
    Exif Offset: 232
    Exif Version: 0221
    Color Space: 65535
    Exif Image Width: 675
    Exif Image Length: 286
  Profile-XMP: 3222 bytes
  Tainted: False
Apr 12, 2014 at 7:21 AM
Can you add a link to your GM output image? It is strange that identify does not report an embedded icc profile.
Apr 15, 2014 at 12:32 PM
gm convert 00000003.jpg -profile sRGB.icc 3convert.jpg

gm convert 00000003.jpg -profile sRGB.icc -colorspace RGB 3convertRGB.jpg
Apr 15, 2014 at 2:48 PM
I checked the source code of GraphicsMagick and they also only convert the colors when there is a source profile. Your 3convert.jpg image is still CMYK and 3convertRGB.jpg only had its colorspace changed and was not converted. It looks too blue on my monitor. With the following code I come really close to your CMYK source image.
using (MagickImage image = new MagickImage("00000003.jpg"))
The colors will never be the same but the colors of 00000003.rgb.jpg are closer too 00000003.jpg then your 3convertRGB.jpg image. When you look at the bottom 'Sugerdale' logo the color is too red compared with the original image. And the meat on the right is too purple in the centre.
Apr 18, 2014 at 12:56 PM
Thanks. I agree the colors are closer but they are still off. I'm not looking for perfection but perceptibly correct would be nice. Is there really no way to convert these images to match?
Apr 18, 2014 at 2:32 PM
Edited Apr 18, 2014 at 6:54 PM
You will never exactly match the colors. A bit more information can be found here:


I have tried a couple more profiles and it looks like you get a better result with the 'USWebUncoated.icc' CMYK profile. You can download that here:
Oct 21, 2014 at 3:43 PM
I have another question regarding this topic. Please look at this image Cereal Is there any hope of converting this to an image in either RGB or CMYK JPEG or PNG that looks normal? This image opens up in Photoshop and looks great but all the typical viewers I used display this image in funky green colors. I'm guessing that I'm out of luck on this one too because I do not see an embedded profile. Thanks for your help.

Here's the gm.exe identify output.
λ gm identify -verbose 112913_ACM_CIR_GATE_V01_ALL_p1_1.tif
Image: 112913_ACM_CIR_GATE_V01_ALL_p1_1.tif
Format: TIFF (Tagged Image File Format)
Geometry: 271x359
Class: DirectClass
Type: color separated
Depth: 8 bits-per-pixel component
Channel Depths:
Cyan:     8 bits
Magenta:  8 bits
Yellow:   8 bits
Black:    8 bits
Channel Statistics:
  Minimum:                  5911.00 (0.0902)
  Maximum:                 65535.00 (1.0000)
  Mean:                    49718.69 (0.7587)
  Standard Deviation:      15650.08 (0.2388)
  Minimum:                     0.00 (0.0000)
  Maximum:                 63479.00 (0.9686)
  Mean:                    30915.05 (0.4717)
  Standard Deviation:      12021.98 (0.1834)
  Minimum:                 10537.00 (0.1608)
  Maximum:                 63736.00 (0.9725)
  Mean:                    33732.91 (0.5147)
  Standard Deviation:       9256.98 (0.1413)
  Minimum:                     0.00 (0.0000)
  Maximum:                     0.00 (0.0000)
  Mean:                        0.00 (0.0000)
  Standard Deviation:          0.00 (0.0000)
Resolution: 200x200 pixels/inch
Filesize: 87.8K
Interlace: No
Orientation: Unknown
Background Color: white
Border Color: #DFDFDF
Matte Color: #BDBDBD
Page geometry: 271x359+0+0
Compose: Over
Dispose: Undefined
Iterations: 0
Compression: JPEG
Signature: ff7e4f16022c10de4f35fea4c42b8a55827d983d75ea015e7fe0f75972406043
Tainted: False

Tiffinfo.exe output

λ tiffinfo 112913_ACM_CIR_GATE_V01_ALL_p1_1.tif
TIFF Directory at offset 0x15e50 (89680)
Image Width: 271 Image Length: 359
Resolution: 200, 200 pixels/inch
Bits/Sample: 8
Compression Scheme: JPEG
Photometric Interpretation: separated
Samples/Pixel: 4
Rows/Strip: 359
Planar Configuration: single image plane

Oct 23, 2014 at 12:42 PM
It looks odd in all the programs I use to view it. Can you show me how it looks in Photoshop?
Oct 23, 2014 at 1:44 PM
Edited Oct 23, 2014 at 2:46 PM
Sure. Here's a link to a screenshot with the image loaded in Photoshop.

It may also work in gimp but i haven't tried it yet.

Update: Nope GIMP doesn't work. It doesn't look like it support CMYK.
Oct 23, 2014 at 10:18 PM
I am not sure if I can fix this since other viewers also show the image 'greenish' but I will try to take a look at it this weekend.
Oct 26, 2014 at 8:57 PM
Edited Oct 27, 2014 at 6:06 AM
I took me a while but I figured out how Photoshop determines the colors. In the metadata of the image there is a part that tells me the pixels are stored as YCCK instead of CMYK. The next version of Magick.NET ( will detect this and create an image with the correct colors. I was able to create the following image with your sample image:
Oct 27, 2014 at 7:33 PM
Awesome! The dropbox image looks great. Thanks.
Oct 27, 2014 at 8:41 PM
Edited Oct 27, 2014 at 8:44 PM
Your welcome but you should really watch this Ted talk: What I did does not qualify as awesome :P

p.s. I moved the release of Magick.NET forward, you can download it now.
Oct 28, 2014 at 12:25 AM
ok, I stand corrected. Your changes were not awesome. Your changes didn't rival the wheel nor did they rival the pyramids at Giza. So let me rephrase. Thanks for doing a slightly above adequate job and letting me know when it was finished. ;)

I'll test it out tomorrow.

Oct 28, 2014 at 6:27 PM
Edited Oct 28, 2014 at 6:28 PM
Tested it. Works great. Thanks for the non-awesome update.