how to paste png into ipython julia notebook?

1,462 views
Skip to first unread message

Edward Chen

unread,
Mar 11, 2015, 12:05:07 PM3/11/15
to julia...@googlegroups.com
from IPython.display import Image
Image(filename='image.png')

doesn't seem to work

Thanks!
-Ed

Isaiah Norton

unread,
Mar 11, 2015, 12:37:51 PM3/11/15
to julia...@googlegroups.com
That is Python code, so it won't work in IJulia. You might be able to use PyCall:

Or use the Julia Images package to load the file:

Once you have an image loaded, then `display(img)` should work.

Patrick O'Leary

unread,
Mar 11, 2015, 12:40:03 PM3/11/15
to julia...@googlegroups.com

Edward Chen

unread,
Mar 13, 2015, 10:54:17 AM3/13/15
to julia...@googlegroups.com
Awesome, thanks for the quick response!

Steven G. Johnson

unread,
Mar 13, 2015, 11:42:42 AM3/13/15
to julia...@googlegroups.com

Randy Zwitch

unread,
Mar 13, 2015, 11:44:57 AM3/13/15
to julia...@googlegroups.com
You can also use plain HTML in a markdown cell.


On Wednesday, March 11, 2015 at 12:05:07 PM UTC-4, Edward Chen wrote:

Steven G. Johnson

unread,
Mar 13, 2015, 11:50:32 AM3/13/15
to julia...@googlegroups.com


On Friday, March 13, 2015 at 11:44:57 AM UTC-4, Randy Zwitch wrote:
You can also use plain HTML in a markdown cell.

Yes, you can use <img ...> tags, but then the image data is not included in the notebook file itself, so unless the image is on a server somewhere that makes it more annoying to share the notebook (as you have to remember to copy the image file along with the notebook). 

Jameson Nash

unread,
Mar 13, 2015, 11:59:14 AM3/13/15
to julia...@googlegroups.com
the src url of the <img ...> tag can itself be a base64 encoded image: http://en.wikipedia.org/wiki/Data_URI_scheme#HTML

Randy Zwitch

unread,
Mar 13, 2015, 12:01:43 PM3/13/15
to julia...@googlegroups.com
True. I share my notebooks as GitHub repos, so I've always passed the images along.

Jiahao Chen

unread,
Mar 13, 2015, 12:14:34 PM3/13/15
to julia...@googlegroups.com
You can also base64 encode an image and paste the resulting string
into a HTML img tag. Works well for smaller images, but might get
unwieldy for larger ones.

Steven G. Johnson

unread,
Mar 8, 2016, 10:45:50 AM3/8/16
to julia-users
Jupyter just added a feature to drag-and-drop or paste images into markdown cells that should make it a lot easier to create notebooks with technical illustrations: https://github.com/jupyter/notebook/pull/621
Reply all
Reply to author
Forward
0 new messages