title: How to check the channel order of an image?
body: <h2>Question</h2>
  <p>With an image loaded into Python as shown below, how do I know which order the channels are in? (e.g. BGR or RGB)</p>
  <p><strong>Code</strong></p>
  <pre><code>from PIL import Image
  import numpy as np
  
  image_pil = Image.open(&quot;Stonehenge.jpg&quot;)
  image_np = np.array(image_pil)
  image_np[0][0]
  </code></pre>
  <p><strong>Result</strong></p>
  <pre><code>array([ 52, 123, 155], dtype=uint8)
  </code></pre>
  <p><strong>Specific question</strong></p>
  <p>How do I know whether the <code>52</code> corresponds to the red channel, the blue channel, or a different channel? Or does this question not make sense on a conceptual level?</p>
  <hr />
  <h2>Notes</h2>
  <p>In a similar question for <strong>Java</strong> instead of Python, <a href="https://stackoverflow.com/a/44359400/3822261">one person claims</a>:</p>
  <blockquote>
  <p>If you are reading in the image file, or you have access to the code
  that reads in the file, know it is:</p>
  <ul>
  <li>BGR order if you used cv2.imread(),</li>
  <li>RGB order if you used mpimg.imread(), (assuming import matplotlib.image as mpimg)</li>
  </ul>
  <p>If you don't know how the file was opened, the accepted answer
  BufferedImage is great for Java.</p>
  </blockquote>