title: Create real grayscale images using C#
body: <p>I'm trying to create a real grayscale image, but when my designer checks the file he is saying that the image remains RGB.</p>
  
  <p>You can see the photoshop print here:
  <a href="https://i.stack.imgur.com/eQ5Jo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eQ5Jo.jpg" alt="enter image description here"></a></p>
  
  <p>I've tried 2 methods so far:</p>
  
  <p>1) Using the MakeGrayScale3 method:</p>
  
  <pre><code>    public static Image MakeGrayscale3(Image original)
      {
          //create a blank bitmap the same size as original
          Bitmap newBitmap = new Bitmap(original.Width, original.Height);
          newBitmap.SetResolution(original.HorizontalResolution, original.VerticalResolution);
  
          //get a graphics object from the new image
          Graphics g = Graphics.FromImage(newBitmap);
  
          //create the grayscale ColorMatrix
          ColorMatrix colorMatrix = new ColorMatrix(
             new float[][] 
                {
                   new float[] {.3f, .3f, .3f, 0, 0},
                   new float[] {.59f, .59f, .59f, 0, 0},
                   new float[] {.11f, .11f, .11f, 0, 0},
                   new float[] {0, 0, 0, 1, 0},
                   new float[] {0, 0, 0, 0, 1}
                });
  
          //create some image attributes
          ImageAttributes attributes = new ImageAttributes();
  
          //set the color matrix attribute
          attributes.SetColorMatrix(colorMatrix);
  
          //draw the original image on the new image
          //using the grayscale color matrix
          g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
             0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);
  
          //dispose the Graphics object
          g.Dispose();
          return newBitmap;
      }
  </code></pre>
  
  <p>2) Using the ImageMagick.Net library with this code:</p>
  
  <pre><code>                            using (MagickImage image = new MagickImage(file))
                              {
                                  image.ColorSpace = ColorSpace.GRAY;
  
                                  image.Write(originalFile);
                              }
  </code></pre>
  
  <p>If anyone had this problem before or have a clue of what to do to change that..</p>
  
  <p>Thanks!</p>
  
  <p>Original Image:</p>
  
  <p><a href="https://i.stack.imgur.com/FcSHw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FcSHw.jpg" alt="enter image description here"></a></p>
  
  <p>Result Image (ImageMagick):</p>
  
  <p><a href="https://i.stack.imgur.com/7G2yI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7G2yI.jpg" alt="enter image description here"></a></p>
  
  <p>Result Image (MakeGrayscale3):</p>
  
  <p><a href="https://i.stack.imgur.com/LMIOA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LMIOA.jpg" alt="enter image description here"></a></p>