title: In Python, how to convert array of bits to array of bytes?
body: <p>Python PIL library has <code>Image.getdata()</code> method, which return raw image data, writing:</p>
  
  <pre><code>list(im.convert("1").getdata())
  </code></pre>
  
  <p>will return an array of bits. Each bit corresponds to one image pixel - pixel can only be black or white because of "1" mode.</p>
  
  <p>I would like to have an array which size is 8 times smaller. Each array element contains one byte.</p>
  
  <p>My questions are:</p>
  
  <ul>
  <li><strong>1. Can I get such an array of bytes directly from PIL?</strong></li>
  <li><strong>2. If not, how to convert array of bits returned by PIL to smaller array of bytes?</strong></li>
  </ul>