title: How can I construct a PIL Image from an array of RGBA pixels?
body: <p>My goal is to use PIL to extract some details from an image, effectively cropping it down.<br />
  For this, I use <code>Image.getdata()</code> to get a list of the pixels in the image, since checking and modifying this is easier for me.</p>
  <p>After all the changes I made, I am left with an array of pixels represented in tuples. For simplicity, an array like that could look like this:</p>
  <pre class="lang-py prettyprint-override"><code>new_pixels = [
      (255, 0, 0, 255),
      (0, 255, 0, 255),
      (0, 0, 255, 255),
      (0, 0, 0, 255)
  ]
  </code></pre>
  <p>I've seen something interesting in the PIL documentation, namely <a href="https://pillow.readthedocs.io/en/4.0.x/reference/Image.html#PIL.Image.fromarray" rel="nofollow noreferrer">the <code>fromarray</code> classmethod</a>, however passing the array to this function gives an error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;C:\Python39\lib\site-packages\PIL\Image.py&quot;, line 2741, in fromarray
      arr = obj.__array_interface__
  AttributeError: 'list' object has no attribute '__array_interface__'
  </code></pre>
  <p>Trying the same with a two dimensional list gives the same result.</p>
  <p>The question finally is, how would I go about turning this array into a PIL Image object that I can later save?</p>