title: How to get bit depth of a bitmap image
body: <p>I have images where I want to know the bit depth of the .bmp image. This is quite easy in windows manually (Properties&gt;Details..) but there doesn't seem to much from google on it and the one answer I saw on here didn't (for me) show how to do it.</p>
  <p><a href="https://stackoverflow.com/questions/31619140/how-to-find-the-bit-depth-of-an-image">How to find the Bit Depth of an image</a></p>
  <p><strong>Code</strong></p>
  <pre><code>import png as png
  import numpy as np
  
  r=png.Reader(filename = r'C:\Users\priper\Desktop\OPW_refac\grayscale.png')
  a = r.read()
  
  print(a[3]['bitdepth'])
  </code></pre>
  <p>or</p>
  <pre><code>from PIL import Image
  import numpy as np
  
  #Load the BMP file    
  img = Image.open(r'C:\Users\priper\Desktop\OPW_refac\HSS All As.bmp')
  print(img, '\n')
  print('bit depth :', img.mode)#this only tells me it is 8 pixels, I don't think it could tell me if it was 4.
  
  #Or as a numpy array
  img = np.array(Image.open(r'C:\Users\priper\Desktop\OPW_refac\HSS All As.bmp'))
  print(img)
  </code></pre>
  <p>I can read the bit depth of a png but haven't a clue which library can get similar information so easily from a bmp.</p>