DEV Community

Dmitry Matuzko
Dmitry Matuzko

Posted on

Converting RGB TIFF to CMYK TIFF with Aspose.Imaging 18.3

In Aspose.Imaging 18.3 an new option has appeared which may be useful to some: an ability to convert from RGB color space to CMYK color space.
To save a image in CMYK color space, you have to use CMYK-capable file format (In the example, it's TIFF), set it up to use CMYK color space ( By creating TiffOptions with a TiffLzwCmyk value of TiffExpectedFormat enum in the example) and provide a color profile mapping to CMYK color space.

Here is the complete example in C# using Aspose.Imaging for .NET 18.3:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Aspose.Imaging.FileFormats.Tiff;
using Aspose.Imaging.ImageOptions;
using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Tiff.Enums;
using Aspose.Imaging.Sources;

namespace ImagingExample
    class Program
        static void Main(string[] args)
            string sourceFilePath = "testTileDeflate.tif";
            string outputFilePath = "testTileDeflate Cmyk Icc.tif";
            string cmykProfilePath = "RSWOP.ICM";

            //Load the output color profile
            MemoryStream cmykProfile;
            using (FileStream stream = new FileStream(cmykProfilePath, FileMode.Open))
                byte[] bytes = new byte[stream.Length];
                stream.Read(bytes, 0, (int)stream.Length);
                cmykProfile = new MemoryStream(bytes);

            //Set up save file format parameters
            TiffOptions options = new TiffOptions(TiffExpectedFormat.TiffLzwCmyk);
            options.IccProfile = cmykProfile;

            //Load and save
            using (Image image = Image.Load(sourceFilePath))
                image.Save(outputFilePath, options);

Enter fullscreen mode Exit fullscreen mode

As seen, conversion is very simple to perform using Aspose.Imaging.

For more examples please visit the Aspose.Imaging GitHub page. There's also Twitter and Facebook pages for news on Aspose.Imaging.

Top comments (0)