title: Number of channels in pil (pillow) image
body: <p>I am trying to find a way to get the number of channels of an image using Pillow. This seems rather trivial but I couldn't find it (the simple answer).</p>
  <p>I know I can work it around with a minor overhead like (2 possibilities thought):</p>
  <ul>
  <li>Convert to numpy and check <code>array.shape</code></li>
  <li>Check <code>image.size[0]*image.size[1]</code> against <code>len(image.getdata())</code></li>
  </ul>
  <p>so I am not really interested in finding a working solution but rather in accomplishing this using pillow.</p>
  <p>The code I am using is straight forward:</p>
  <pre><code>from PIL import Image
  
  image = Image.open(image_path)
  image.size  # &lt;- this gives the size of the image but not the channel as in numpy.
  </code></pre>
  <blockquote>
  <p>(609, 439)</p>
  </blockquote>
  <p>I also found this approach inspired by this <a href="https://stackoverflow.com/a/42872779/3584765">answer</a> (which also imports overhead of course):</p>
  <pre><code>num_channel = len(image.split())
  </code></pre>
  <p>To me it seems really peculiar I cannot find this simple answer.</p>