Q:

Empty info for PIL.Image.fromarray

My goal is to print inline an image inside a IPython notebook. The image is built with the function PIL.Image.fromarray. More specifically, here is what happens. When I run
import numpy as np
from PIL import *

image = Image.open('image.png')
image_pixels = np.array(image.getdata())
image_rec = Image.fromarray(image_pixels.reshape(image.size[0], image.size[1]))
image_rec

I get a black picture inside the notebook. However, when I replace the last line by image_rec.show(), it correctly opens a window with image inside.
After looking, I noticed that image_rec.info is actually empty {} whereas image.info contains {'compression': 'raw', 'dpi': (72.0000084, 72.0000084)}. What is happening? How can I fix it?

A:

The  info is something the writer adds. Saving the image with some options and reading it back, fills the info dictionary:
image_rec.save('image2.png', dpi=(72, 72))
im2 = PIL.Image.open('image2.png')

Now:
>>> im2.info
{'dpi': (72, 72)}

