---
title: "Rgb To Cmyk color space conversion"
canonical: https://www.graphicsmill.com/samples/ColorManagement/RGBToCMYK/RgbToCmyk_cs
product: "Graphics Mill"
source: "ColorManagement/RGBToCMYK/RgbToCmyk.cs"
---

# Rgb To Cmyk color space conversion

Converts color space from RGB to CMYK with color management.

## Instruction

Converts an RGB image to CMYK with color management using the object-based API.

## Usings

```csharp
using Aurigma.GraphicsMill.Transforms;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap("Copenhagen_RGB.jpg"))
{
    if (bitmap.ColorProfile == null)
    {
        bitmap.ColorProfile = ColorProfile.FromSrgb();
    }

    bitmap.ColorManagement.DestinationProfile = new ColorProfile("ISOcoated_v2_eci.icc");
    bitmap.ColorManagement.TransformationIntent = ColorTransformationIntent.Perceptual;

    bitmap.ColorManagement.Convert(PixelFormat.Format32bppCmyk);

    bitmap.Save("RgbToCmykWithColorManagement.jpg");
}
```

## Explanation

The code:

- Loads "Copenhagen_RGB.jpg" into a `Bitmap`.
- Assigns the sRGB color profile if none is embedded.
- Sets the destination profile to "ISOcoated_v2_eci.icc", a common CMYK press profile.
- Uses perceptual intent to preserve visual appearance across different color gamuts.
- Converts the pixel format to `Format32bppCmyk`.
- Saves the resulting CMYK image as "RgbToCmykWithColorManagement.jpg".

## Tags

- [Bitmap](<https://www.graphicsmill.com/samples/tags/bitmap_md>): Working with images via the Bitmap API
- [Color Conversion](<https://www.graphicsmill.com/samples/tags/color-conversion_md>): Converting colors between color spaces
- [Color Management](<https://www.graphicsmill.com/samples/tags/color-management_md>): Color management with ICC profiles

## Input

- [Copenhagen\_RGB.jpg](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/Copenhagen_RGB_jpg>) (preview)
- [ISOcoated\_v2\_eci.icc](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/ISOcoated_v2_eci_icc>) (download)

## Output

- [RgbToCmykWithColorManagement.jpg](<https://www.graphicsmill.com/samples/ColorManagement/compiled/Debug/RgbToCmykWithColorManagement_jpg>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.ColorManagement](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Bitmap_ColorManagement.htm.md>)
- [Aurigma.GraphicsMill.Bitmap.ColorProfile](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Bitmap_ColorProfile.htm.md>)
- [Aurigma.GraphicsMill.ColorManagementProvider.Convert(PixelFormat)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_ColorManagementProvider_Convert_1_3e209c07.htm.md>)
- [Aurigma.GraphicsMill.ColorManagementProvider.DestinationProfile](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_ColorManagementProvider_DestinationProfile.htm.md>)
- [Aurigma.GraphicsMill.ColorManagementProvider.TransformationIntent](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_ColorManagementProvider_TransformationIntent.htm.md>)
- [Aurigma.GraphicsMill.ColorProfile](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_ColorProfile.htm.md>)
- [Aurigma.GraphicsMill.ColorProfile.FromSrgb](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_ColorProfile_FromSrgb.htm.md>)
- [Aurigma.GraphicsMill.Transforms.ColorTransformationIntent](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Transforms_ColorTransformationIntent.htm.md>)
