title: PIL/Pillow convert Image to list and back again
body: <p>I'm trying to open an RGB picture, convert it to grayscale, then represent it as a list of floats scaled from 0 to 1. At last, I want to convert it back again to an Image. However, in the code below, something in my conversion procedure fails, as <code>img.show()</code> (the original image) displays correctly while <code>img2.show()</code> display an all black picture. What am I missing?</p>
  
  <pre><code>import numpy as np
  from PIL import Image
  
  ocr_img_path = "./ocr-test.jpg"
  
  # Open image, convert to grayscale
  img = Image.open(ocr_img_path).convert("L")
  
  # Convert to list
  img_data = img.getdata()
  img_as_list = np.asarray(img_data, dtype=float) / 255
  img_as_list = img_as_list.reshape(img.size)
  
  # Convert back to image
  img_mul = img_as_list * 255
  img_ints = np.rint(img_mul)
  img2 = Image.new("L", img_as_list.shape)
  img2.putdata(img_ints.astype(int))
  
  img.show()
  img2.show()
  </code></pre>
  
  <p><a href="https://pixabay.com/static/uploads/photo/2014/08/07/21/13/newspaper-412811_960_720.jpg" rel="nofollow">The image used</a></p>