Question: I've developed a few phonegap apps for ios and now I want to create android versions for one of them. The thing with android is, of course, that it is used on so many different devices. I understand that the safest way is to test the app on every single device that I'm targeting, but is there a smart and easy solution to test for as many devices as possible without buying 20 new phones? Is the emulator, for example, reliable? 

Any hints and tips from you android phonegap guys and girls out there much appreciated!

Answer: 
Updated 2021/11/17
------------------

When using PIL/Pillow, Jupyter Notebooks now have a `display` built-in that will show the image directly, with no extra fuss.

```
display(pil_im)

```

Jupyter will also show the image if it is simply the last line in a cell (this has changed since the original post). Thanks to answers from [@Dean](https://stackoverflow.com/a/64537316/213525) and [@Prabhat](https://stackoverflow.com/a/59470127/213525) for pointing this out.

Other Methods
-------------

### From File

You can also use IPython's `display` module to load the image. You can read more from [the doc](https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.Image).

```
from IPython.display import Image 
pil_img = Image(filename='data/empire.jpg')
display(pil_img)

```

### From PIL.Image Object

As OP's requirement is to use `PIL`, if you want to show inline image, you can use `matplotlib.pyplot.imshow` with `numpy.asarray` like this too:

```
from matplotlib.pyplot import imshow
import numpy as np
from PIL import Image

%matplotlib inline
pil_im = Image.open('data/empire.jpg', 'r')
imshow(np.asarray(pil_im))

```

If you only require a preview rather than an inline, you may just use `show` like this:

```
pil_im = Image.open('data/empire.jpg', 'r')
pil_im.show()

```
case python3

```
from PIL import Image
from IPython.display import HTML
from io import BytesIO
from base64 import b64encode

pil_im = Image.open('data/empire.jpg')
b = BytesIO()  
pil_im.save(b, format='png')
HTML("<img src='data:image/png;base64,{0}'/>".format(b64encode(b.getvalue()).decode('utf-8')))

```