Using JPEG image with CMYK format in Internet Explorer by converting it to RGB

Recently, I faced an unusual problem while working with JPEG images in a project. What I found is that some of the images with .jpg extension were not being displayed in Internet Explorer, instead a red mark displayed where the image should have been. Further research revealed that Internet Explorer was unable to display images which are encoded in the CMYK format rather than the regular RGB format.
So what is this CMYK format ?

CMYK (Cyan-Magenta-Yellow-blacK) is a color system representing 147 colors defined by the Scalable Vector Graphics (SVG) Specification. The CMYK color system is mainly used in printing inks for paper and not meant to be used in HTML or Cascading Style Sheets but are recognized by the latter.
For more details go through the link :- http://www.december.com/html/spec/colorsvgcmyk.html

Windows supports three-channel RGB format only and since Internet Explorer is primarily built on the Windows, it too doesn’t support four-channel CMYK format. However, Firefox and Chrome have no such problem and can display a four-channel format image as well as a three-channel format image.

Solution
The easiest solution would be to open the image using Image editors such as Adobe Photoshop,Gimp, Paintbrush etc but there are online services too that can convert a CMYK image to RGB image. http://www.cmykconverter.com/ is one of them.

The following code snippet demonstrates how to check if an image is CMYK or RGB encoded-

Take a file uploader and a button in the page designer.
Ex:-

         
    

We can have the following code to detect the jpg file type at the button click event:-
Ex:-

 System.Drawing.Bitmap uploadedImage = new System.Drawing.Bitmap(myUpload.PostedFile.InputStream);
            if (isCMYKJpeg(uploadedImage))
            {  result.Text = "CYMK jpg type.";  }
            else
            {  result.Text = "RGB jpg type.";  }
       
Then the function 'isCMYKJpeg' can be defined as follows:-
 
protected bool isCMYKJpeg(System.Drawing.Image image)
    {
        System.Drawing.Imaging.ImageFlags flagValues = (System.Drawing.Imaging.ImageFlags)Enum.Parse
(typeof(System.Drawing.Imaging.ImageFlags), image.Flags.ToString());
        if (flagValues.ToString().ToLower().IndexOf("ycck") == -1)
[ to know about ycck please follow the link :- "http://software.intel.com/sites/products/documentation
/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html"]
        {  return false;  }
        return true;
    }
150 150 Burnignorance | Where Minds Meet And Sparks Fly!