none
Get Color Mode (CMYK or RGB) of an JPEG Image ?

    Question

  • Is there any way to get color mode (CMYK or RGB) of an JPEG image using C#.code?
    Tuesday, November 18, 2008 5:41 AM

Answers

  • Hi,

    You know that every image has its header on the first few bytes in it in which all information is saved regarding its, bit depth, compression type, pixelformat, color mode (RGB or CMYK).

    If this all not works then I think that we have to read header of the input image. The above code project link, I have specified above shows, how to read input image pixel by pixel or etc.  On the basis of that header image we can place a check and conclude whether the image is in RGB mode or CMYK mode.

    Only few softwares support CMYK and RGB both e.g, Adobe photoshop.
    Just imagine that some information will definitely be stored in the header of image on which photoshop decides whether it opens the selected image in RGB mode or CMYK mode.

    We have to do that all manually.

    please visit the following links.

    http://www.codeproject.com/KB/mcpp/BitmapHandler.aspx?display=Print
    http://www.awitness.org/delphi_pascal_tutorial/source2/bitmap_file_format.html
    http://www.inversereality.org/tutorials/graphics%20programming/bitmaploading.html


    --
    Regards,
    Asif

    Software Developer
    Thursday, November 20, 2008 10:26 AM
  • hi,

    I have not tested that but may be this will works for you.

    try to use.

    Bitmap object.PixelFormat

    This property gets or sets the format of pixel information.

    Here are some links about "how to play with images in C#.NET". Here programming is done according to storage structure of RGB images.
    I think we need understandand the storage structure of CMYK JPEG images and also RGB images in C#(means how C#.NET load these images ). and then we specify a check here to see whether the input image is RGB or CMYK.

    http://www.codeproject.com/KB/GDI-plus/displacementfilters.aspx

    --
    Regards,
    Asif

    Software Developer
    Tuesday, November 18, 2008 9:38 AM

All replies

  • According to Wikipedia jpg files are in YCbCr format, but some use RGB.
    Ron Whittle - If the post is helpful or answers your question, please mark it as such.
    Tuesday, November 18, 2008 5:54 AM
  • Hi. Ron,
     
         Thanks for your reply.i have designed the image using PhotoShop with the option Image->Mode->CMYK Color (Menu option).

     So i want to find what are all the images in a specific folder having the CMYK color Mode using C#.net code.
    Tuesday, November 18, 2008 7:11 AM
  • hi,

    I have not tested that but may be this will works for you.

    try to use.

    Bitmap object.PixelFormat

    This property gets or sets the format of pixel information.

    Here are some links about "how to play with images in C#.NET". Here programming is done according to storage structure of RGB images.
    I think we need understandand the storage structure of CMYK JPEG images and also RGB images in C#(means how C#.NET load these images ). and then we specify a check here to see whether the input image is RGB or CMYK.

    http://www.codeproject.com/KB/GDI-plus/displacementfilters.aspx

    --
    Regards,
    Asif

    Software Developer
    Tuesday, November 18, 2008 9:38 AM
  • Hi.Asif,
                  Thanks for your reply.

               Bitmap object.PixelFormat always returns Format24bppRgb for both CMYK and RGB. i can't get the color mode using the code project link. 

    Regards,
    Jayakumar
    Thursday, November 20, 2008 9:36 AM
  • Hi,

    You know that every image has its header on the first few bytes in it in which all information is saved regarding its, bit depth, compression type, pixelformat, color mode (RGB or CMYK).

    If this all not works then I think that we have to read header of the input image. The above code project link, I have specified above shows, how to read input image pixel by pixel or etc.  On the basis of that header image we can place a check and conclude whether the image is in RGB mode or CMYK mode.

    Only few softwares support CMYK and RGB both e.g, Adobe photoshop.
    Just imagine that some information will definitely be stored in the header of image on which photoshop decides whether it opens the selected image in RGB mode or CMYK mode.

    We have to do that all manually.

    please visit the following links.

    http://www.codeproject.com/KB/mcpp/BitmapHandler.aspx?display=Print
    http://www.awitness.org/delphi_pascal_tutorial/source2/bitmap_file_format.html
    http://www.inversereality.org/tutorials/graphics%20programming/bitmaploading.html


    --
    Regards,
    Asif

    Software Developer
    Thursday, November 20, 2008 10:26 AM