Comments (14)
If you want to display graphics in a markdown cell, you can reference a file on your local filesystem:
![Python Logo](files/python-logo.svg)
or
<img src="python-logo.svg" />
Dropping an image into a markdown cell is only interesting if you want to save the image data in the notebook itself.
Dragging images out of a notebook creates a base64-coded blob in the combination Windows+Firefox. On Linux or using Chrome get an image when you drop it.
from jupyter_contrib_nbextensions.
Hmm.. my workflow is:
- Screenshot >> paste into OneNote or Confluence Wiki
So the question was, how to create a markdown cell (as you shown), but with a dynamically created file based on the pasted image?
from jupyter_contrib_nbextensions.
Acually, if you drop an image from Confluence into a notebook, you get a link to the image instead of a blob. I guess this is what you wand.
I did not know that and tried it just now. This is nice!
from jupyter_contrib_nbextensions.
The pattern is maybe something like that:
- https://github.com/JoelBesada/pasteboard
And in general it should be possible to use the Tornado for storing the images?
No idea, if there are dragons on that route :)
from jupyter_contrib_nbextensions.
Yeah, the Confluence support for dynamic generation of an attachment and instant generating the link to it, was key for usage web-based wiki for documentation.
Google Mail supports this copy/paste as well... I think it is a HTML5 thing, which makes it possible.
from jupyter_contrib_nbextensions.
Hmm.. I just experienced the creation of a markdown cell, after I dragged the today Google Doodle into the notebook:
<img src="https://www.google.de/search?q=Gabriele+M%C3%BCnter&oi=ddle&ct=gabriele-munters-137th-birthday-5701221226643456-hp&rlst=f&hl=de"/>
But it cannot be shown, due to error on console:
Resource interpreted as Image but transferred with MIME type text/html: "https://www.google.de/search?q=Gabriele+M%C3%BCnter&oi=ddle&ct=gabriele-munters-137th-birthday-5701221226643456-hp&rlst=f&hl=de".
And no, this was not not what I expected, or what I wanted to motivate with my Confluence example :)
I have tried to describe the use case, of
- "pasting" an image from the clipboard (essential for screenshotting workflow)
- which should be uploaded to the ipython server (instead of base64 blob)
- and to create a markdown with an img reference to this local file
Btw: testing the drag/drop extension: dragging JPG/PNG from my local window explorer to the notebook, has no effect and error at all :(
sry for the long comment
(=PA=)
from jupyter_contrib_nbextensions.
Still researching.. no Python solution found, but this one looks most promising to issue a ajax post request on the recieved clipboard data:
Google search keywords used: html5 clipboard 2013 post ajax
from jupyter_contrib_nbextensions.
Thanks for digging into this. I will look at it later.
from jupyter_contrib_nbextensions.
Got it to work in Flask, so the blog is on the spot, just copied the div and the scripts!
Now the question is
- where to place the pasteTarget div
- how not to interfere with textual copy/paste
- to inject the markdown with the reference to the uploaded img
Would be great if you can "wire" it into ipy notebook!
The simple Flask method to receive the data:
@app.route('/upload', methods=['POST'])
def upload():
app.logger.info('data: %r' % len(request.data))
file('test.png', 'w').write(request.data)
return 'ok'
(=PA=)
from jupyter_contrib_nbextensions.
The wiring part in Javascript is only a few lines. I have tried this over the weekend and dragging an image, sending it to the serve,r and saving it there is easy:
http://youtu.be/2HOm7XjKLB8
What is missing and what you really need is support on the notebook server side.
This would help:
ipython/ipython#5190
from jupyter_contrib_nbextensions.
I will look into the nb server side integration, when I will find the next experimentation time slot :)
from jupyter_contrib_nbextensions.
You can try this here:
https://github.com/juhasch/IPython-notebook-extensions/tree/dragdrop-upload/usability/dragdrop
If you put the Python file in the IPython startup directory, it will start a websocket server in a new thread.
Now, dragging images on a notebook will upload the image into an images
directory and create a link to it in a notebook markdown cell. Dragging from the notebook also works partially.
Still WIP.
from jupyter_contrib_nbextensions.
I have merged the new drag and drop extension into this repository.
The old extension with direct base64 embedding into a markdown cell will not work with IPython 2.0 due to HTML sanitiazion and this issue:
http://code.google.com/p/google-caja/issues/detail?id=1558
Embedding base64 images is not possible as part postprocessor in nbconvert.
from jupyter_contrib_nbextensions.
@spex66 seemed to fiddle around with a paste function from the clipboard. I tried to use the recent drag and drop extension. Adding images by drag and drop seems to work fine, but adding them from the clipboard seems to not work.
Is this problem somewhere addressed?
from jupyter_contrib_nbextensions.
Related Issues (20)
- Support for python 3.11 HOT 3
- nbextensions compatibility with notebook-6.5.3. HOT 4
- Error [jupyter_nbextensions_configurator] error loading toggle_all_line_numbers/mainf
- python-markdown new install fails to render {{var}}. Browser error 'TypeError: marked is not a function ' HOT 10
- Is this project on stand-by or near to being abandoned in front of new versions of conda or jupyter notebook? HOT 1
- [collapsible_headings] When using jupyter_server + nbclassic, collapsible headings not working
- Linux installation issues: nbconvert version
- install nbextensions in \site-packages\jupyter_contrib_nbextensions HOT 1
- extensions does not work or only work once
- jupyter_contrib_nbextenions appears to be incompatible with Jupyter Notebook v7. HOT 6
- all the extensions are failed loading HOT 2
- Installation fails on up-to-date JupyterLab installed with `conda -c conda-forge`
- TOC extension is hiding below toolbar HOT 5
- Autoscroll from NBEXTENSIONS not working
- Code Font Size donβt work
- nbextensions conda installation problem HOT 1
- Python markdown not getting variables values
- '"...\MyEnv\Scripts\jupyter-nbextension.exe"' is not recognized as an internal or external command, operable program or batch file.
- Incompatible with Jupyter Notebook v7.0.6 HOT 3
- load config section forbiddened HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jupyter_contrib_nbextensions.