asp. net Method for judging picture mode GRB or CMYK when uploading pictures

  • 2021-08-12 02:27:25
  • OfStack

In this paper, the method of judging the mode of GRB or CMYK when uploading pictures by asp. net is described. Share it for your reference, as follows:


Bitmap bmp = new Bitmap(allow_fileStream); // File path 
allowUpload = stringHelper.IsCMYK(bmp) == "true" ? false : true; // Return true String, the picture is not RGB Pattern 
public string IsCMYK(System.Drawing.Image img)
{
    string isCmyk;
    if ((GetImageFlags(img).IndexOf("Ycck") > -1) || (GetImageFlags(img).IndexOf("Cmyk") > -1))
    {
      isCmyk = "true";
    }
    else
    {
      isCmyk = "false";
    }
    return isCmyk;
}
public string GetImageFlags(System.Drawing.Image img)
{
    ImageFlags FlagVals = (ImageFlags)Enum.Parse(typeof(ImageFlags), img.Flags.ToString());
    return FlagVals.ToString();
}

For more readers interested in asp. net, please check the topics of this site: "asp. net Operation json Skills Summary", "asp. net String Operation Skills Summary", "asp. net Operation XML Skills Summary", "asp. net File Operation Skills Summary", "asp. net ajax Skills Summary" and "asp. net Cache Operation Skills Summary".

I hope this paper is helpful to everyone's asp. net programming.


Related articles: