Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Tamila  
#1 Posted : Sunday, March 9, 2008 9:06:36 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Sometimes Graphics Mill users encounter a problem – when Graphics Mill loads some images created with Adobe Photoshop (or other software), color profile is not recognized by Graphics Mill, although Photoshop does display it. It happens with sRGB color profile.

The reason for it is that Photoshop does not actually embeds sRGB color profiles to the image. It just sets specific EXIF field to mark the image to have sRGB color space. I guess that Adobe developers optimize output image file size this way – since sRGB color profile is always the same and available on every computer, they do not embed this profile to the file.

The workaround for this problem is to check whether the image file contains this EXIF field and whether it equals to sRGB. Here is a code sample which demonstrates how to do it. This is a function which takes the file name of the image to get color profile from. Draw attention that it does not load bitmap into the memory at all.

Code:

static private Aurigma.GraphicsMill.ColorProfile GetColorProfile(string filename)
{
 // Open the file.
 using (Aurigma.GraphicsMill.Codecs.IFormatReader reader = Aurigma.GraphicsMill.Codecs.FormatManager.CreateFormatReader(filename))
 {
  reader.Open(filename);

  // Check whether it contain any data.
  if (reader.FrameCount > 0)
  {
   // Try to load color profile
   Aurigma.GraphicsMill.Codecs.IFrame frame = reader.LoadFrame(0);
   try
   {
    if (frame.ColorProfile != null)
    {
     // If color profile exists, return it.
     return frame.ColorProfile;
    }
    else
    {
     // If no color profile exists, try to check EXIF block
     // to learn whether the image has sRGB color space.
        
     // Check whether EXIF is supported and stored in this image.  
     Aurigma.GraphicsMill.Codecs.IMetadataReadSupport metadata = reader as Aurigma.GraphicsMill.Codecs.IMetadataReadSupport;
     if (metadata!=null && metadata.Exif!=null)
     {

      // Try to find ColorSpace field in EXIF. According to EXIF specs value = 1 means 
      // that the image is sRGB.
      long colorSpaceKey = Aurigma.GraphicsMill.Codecs.ExifDictionary.ColorSpace;
      if (metadata.Exif.Contains(colorSpaceKey) && (int)metadata.Exif[colorSpaceKey] == 1)
      {
       // If it is sRGB, create new sRGB profile and return it.
       return Aurigma.GraphicsMill.ColorProfile.FromSrgb();
      }
     }     
    }
   }
   catch(Aurigma.GraphicsMill.Exception)
   {
   }
  }   
 }
 
 // In all other cases no color profile is defined for the image,
 // so we just return null. 
 return null;
}

Edited by moderator Monday, May 28, 2012 8:45:20 PM(UTC)  | Reason: Not specified

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!

Users browsing this topic
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.