How to show PIL Image in ipython notebook

This is my code

    from PIL import Image
    pil_im ='data/empire.jpg')

I would like to do some image manipulation on it, and then show it on screen.
I am having problem with showing PIL Image in python notebook.

I have tried:

    print pil_im

And just


But both just give me:

    <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=569x800 at 0x10ECA0710>

You can use IPython's Module: display to load the image. You can read more from the Doc.

    from IPython.display import Image 


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 ='data/empire.jpg', 'r')

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

    pil_im ='data/empire.jpg', 'r')


Back to homepage or read more recommendations: