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

Notification

Icon
Error

Options
Go to last post Go to first unread
jens simonsen  
#1 Posted : Wednesday, May 10, 2017 11:17:49 PM(UTC)
jens simonsen

Rank: Newbie

Groups: Guest
Joined: 3/26/2017(UTC)
Posts: 8

Thanks: 3 times
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:

Code:
                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);
                }

Code:

                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);
                }

Code:
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

Fedor  
#2 Posted : Thursday, May 11, 2017 3:21:49 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Guest
Joined: 7/28/2003(UTC)
Posts: 1,660

Thanks: 5 times
Was thanked: 76 time(s) in 74 post(s)
Hi Jens,

Could you post a problem TIFF file?

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

Best regards,

Fedor Skvortsov

jens simonsen  
#3 Posted : Thursday, May 11, 2017 3:38:14 AM(UTC)
jens simonsen

Rank: Newbie

Groups: Guest
Joined: 3/26/2017(UTC)
Posts: 8

Thanks: 3 times
Originally Posted by: Fedor Go to Quoted Post
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.

9404_9404.tif (676kb) downloaded 6 time(s).

Fedor  
#4 Posted : Thursday, May 11, 2017 6:57:05 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Guest
Joined: 7/28/2003(UTC)
Posts: 1,660

Thanks: 5 times
Was thanked: 76 time(s) in 74 post(s)
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.

photoshop.png

So we need to ignore a color profile as well:

Code:
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.

Edited by user Tuesday, May 16, 2017 5:49:15 PM(UTC)  | Reason: Not specified

Best regards,

Fedor Skvortsov

thanks 1 user thanked Fedor for this useful post.
jens simonsen on 5/14/2017(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.