title: converting images to indexed 2-bit grayscale BMP
body: <p>First of all, my question is different to <a href="https://stackoverflow.com/questions/10155092/how-do-i-convert-image-to-2-bit-per-pixel">How do I convert image to 2-bit per pixel?</a> and unfortunately its solution does not work in my case...</p>
  
  <p>I need to convert images to 2-bit per pixel grayscale BMP format. The sample image has the following properties:</p>
  
  <pre><code>Color Model: RGB
  Depth: 4
  Is Indexed: 1
  Dimension: 800x600
  Size: 240,070 bytes (4 bits per pixel but only last 2 bits are used to identify the gray scales as 0/1/2/3 in decimal or 0000/0001/0010/0011 in binary, plus 70 bytes BMP metadata or whatever)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/cEdDG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cEdDG.png" alt="sample"></a></p>
  
  <p>The Hex values of the beginning part of the sample BMP image:
  <a href="https://i.stack.imgur.com/M2ZYc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M2ZYc.png" alt="head of sample image"></a></p>
  
  <p>The 3s represent white pixels at the beginning of the image. Further down there are some 0s, 1s and 2s representing black, dark gray and light gray:
  <a href="https://i.stack.imgur.com/kmmqU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kmmqU.png" alt="mid-part of sample image"></a></p>
  
  <p>With the command below,</p>
  
  <pre><code>convert pic.png -colorspace gray +matte -depth 2 out.bmp
  </code></pre>
  
  <p>I can get <em>visually</em> correct 4-level grayscale image, but wrong depth or size per pixel:</p>
  
  <pre><code>Color Model: RGB
  Depth: 8 (expect 4)
  Dimension: 800x504
  Size: 1,209,738 bytes (something like 3 bytes per pixel, plus metadata)
  (no mention of indexed colour space)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/c9EGF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c9EGF.png" alt="conversion outcome"></a></p>
  
  <p>Please help...</p>