[IPython-User] PIL Display Hooks

Brian Granger ellisonbg@gmail....
Thu Mar 15 16:21:02 CDT 2012


It should definitely be possible to do this.  Here is what I would advise:

* Look into generating raw JPEG/PNG data from an image.  You could
write this to a file and then read it back in, or possible write
straight to a python bytes object.
* Then look into IPython's display protocol.  The best resource on
this is the display_protocol.ipynb example notebook in
IPython/docs/examples/notebooks.

Once you have the raw JPEG, it shouldn't be more than a few lines of
code to hook into the IPython display system.  Once that is done
images will "just work" in the Notebook.

Cheers,

Brian

On Thu, Mar 15, 2012 at 1:38 PM, Michael Hadmack <hadmack@gmail.com> wrote:
> Does anyone know if it is possible to display PIL objects inline in a
> notebook?  It would be nice it these displayed the same way as
> Matplotlib objects.  I cannot find a way to get raw image data out of
> a PIL.Image object right now.  Looks like you can only save to a file
> or file object.  I can't remember right now how to create a file
> object that is just a memory buffer, don't know if this would do the
> trick.
>
> -Mike
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com


More information about the IPython-User mailing list