title: KeyError: ((1, 1, 1280), '|u1') while using PIL's Image.fromarray - PIL
body: <p>I have this code:</p>
  
  <pre><code>from PIL import Image
  import numpy as np
  img = Image.open('img.jpg')
  Image.fromarray(np.array([[np.mean(i, axis=1).astype(int).tolist()]*len(i) for i in np.array(img).tolist()]).astype('uint8')).show()
  </code></pre>
  
  <p>And I am trying to modify the pixels of the image in PIL, however when I run it it gives an error as follows:</p>
  
  <pre><code>KeyError: ((1, 1, 1280), '|u1')
  </code></pre>
  
  <p>Not just that, it also outputs a second error as follows:</p>
  
  <pre><code>TypeError: Cannot handle this data type
  </code></pre>
  
  <p>Is there a way to overcome this?</p>
  
  <p>P.S. I searched and the most related question to mine was:</p>
  
  <p><a href="https://stackoverflow.com/questions/51479140/convert-numpy-array-object-to-pil-image-object">Convert numpy.array object to PIL image object</a></p>
  
  <p>However I don't get it nor know how to implement it.</p>