This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Convert Tiff to jpeg error : The profile doesn't match to color space required

HI. Im trying to make a simple convert from tiff to jpeg using some the examples here how ever i keep running into the error : The profile doesn't match to color space required on some of the tiff files but not all of them.

i also noticed this started after i installed the newest of the graphics mill library.

the variations i have tried is thus:

                using (var reader = new TiffReader(filepath))
                using (var converter = new ColorConverter(PixelFormat.Format32bppCmyk))
                using (var writer = new JpegWriter(outputpath + @"\" + filename + ".jpg"))
                {
                    if (reader.AdobeResources != null)
                    {
                        var adobeResources = new AdobeResourceDictionary();

                        for (var i = 2000; i <= 2997; i++)
                        {
                            if (reader.AdobeResources.Contains(i))
                            {
                                adobeResources[i] = reader.AdobeResources[i];
                            }
                        }

                        writer.AdobeResources = adobeResources;
                    }

                    Pipeline.Run(reader + converter + writer);
                }


                using (var reader = ImageReader.Create(filepath))
                using (var converter = new ColorConverter(PixelFormat.Format32bppCmyk))
                using (var writer = ImageWriter.Create(outputpath + @"\" + filename + ".jpg"))
                {
                    converter.ColorManagementEngine = ColorManagementEngine.LittleCms;
                    converter.DeviceLinkProfile = new ColorProfile(@"profiles\ISOcoated_v2_to_PSOcoated_v3_DeviceLink.icc");
                    converter.DestinationProfile = new ColorProfile(@"profiles\PSOcoated_v3.icc");

                    Pipeline.Run(reader + converter + writer);
                }

using (var reader = new TiffReader(sourceImagePath))
using (var writer = new JpegWriter(outImagePath))
using (var colorConverter = new ColorConverter(writer.GetAppropriatePixelFormat(reader.PixelFormat)))
{
    writer.AdobeResources = reader.AdobeResources;

    Pipeline.Run(reader + colorConverter + writer);
}


those i just some i have tried all of then produce the same error.

i have to ask you guys what am i doing wrong now 🙂. i simply cant get my head around on what im missing. 😞

regrds jens



Hi Jens,

Could you post a problem TIFF file?

You can submit a case if it is more convenient for you.
Fedor;32273
Hi Jens,

Could you post a problem TIFF file?

You can submit a case if it is more convenient for you.


Hi. sure the tiff file should be attached now.

attach #1334

The provided file has an RGB pixel format, but a CMYK color profile is embedded (U.S. Web Coated SWOP v2).

Photoshop shows the following error on the file loading:

The embedded ICC profile cannot be used because the ICC profile is invalid. Ignoring the profile.

attach #1338

So we need to ignore a color profile as well:

using (var reader = new TiffReader(filepath))
using (var converter = new ColorConverter(PixelFormat.Format32bppCmyk))
using (var writer = new JpegWriter(outputpath + @"\" + filename + ".jpg"))
{
	if (reader.AdobeResources != null)
	{
		var adobeResources = new AdobeResourceDictionary();

		for (var i = 2000; i <= 2997; i++)
		{
			if (reader.AdobeResources.Contains(i))
			{
				adobeResources[i] = reader.AdobeResources[i];
			}
		}

		writer.AdobeResources = adobeResources;
	}

	if (reader.ColorProfile == null || reader.ColorProfile.ColorSpace == reader.PixelFormat.ColorSpace)
	{
		Pipeline.Run(reader + converter + writer);
	}
	else
	{
		using (var bitmap = new Bitmap())
		{
			Pipeline.Run(reader + bitmap);

			//Remove incorrect color profile
			bitmap.ColorProfile = null;

			Pipeline.Run(bitmap + converter + writer);
		}
	}
}


P.S. I have to use Bitmap as there is no way to remove an incorrect color profile with the Pipeline approach.