Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy/save image #245

Open
huyiqun opened this issue Mar 31, 2016 · 22 comments
Open

Copy/save image #245

huyiqun opened this issue Mar 31, 2016 · 22 comments
Labels
enhancement 🌟 New feature ideas help wanted Help is desired

Comments

@huyiqun
Copy link

huyiqun commented Mar 31, 2016

When I use %inline mode to plot something, it is not possible to copy or save the image, but only to view it in atom. Is it possible to add such functionality or what is the best workaround on this? I currently connect a qtconsole to the existing hydrogen kernel, and run the plot code there in order to directly right click for copying and saving. Just wonder if this is by any chance doable in atom.

Also, a quick related question: when the output is one line, it does not pop up a small window that has option for copying or opening in a file. Can this be changed?

Thanks!

@n-riesco
Copy link
Collaborator

On 31/03/16 02:57, huyiqun wrote:

When I use %inline mode to plot something, it is not possible to copy or save the image, but only to view it in atom. Is it possible to add such functionality or what is the best workaround on this? I currently connect a qtconsole to the existing hydrogen kernel, and run the plot code there in order to directly right click for copying and saving. Just wonder if this is by any chance doable in atom.

I think this can be easily done. I'll mark this issue as an enhancement.

Also, a quick related question: when the output is one line, it does not pop up a small window that has option for copying or opening in a file. Can this be changed?

If you click on a one-line bubble, Hydrogen will copy its content to the clipboard.

@n-riesco n-riesco added the enhancement 🌟 New feature ideas label Mar 31, 2016
@lgeiger
Copy link
Member

lgeiger commented Mar 31, 2016

Which language are you using?

For example in python with matplotlib you can do this very easily with plt.savefig('example.pdf')

@rgbkrk
Copy link
Member

rgbkrk commented Mar 31, 2016

I'm guessing you're looking for browser style "right-click -> save image"?

screenshot 2016-03-31 07 33 08

@huyiqun
Copy link
Author

huyiqun commented Mar 31, 2016

I am using python and looking for exactly what @rgbkrk has shown. I know saving to a file would be one option, but just wonder if a temporary copy and paste is possible as I am quite used to such functionality. :)

@nbara
Copy link

nbara commented Jan 10, 2017

+1 for this!

what @rgbkrk is suggesting is exactly what I am looking for, as I am running my code on a remote notebook, hence plt.savefig() would save the file to the remote computer, not on my local machine...

@tobiasbj
Copy link

tobiasbj commented Mar 9, 2017

+1!

@weimindong2016
Copy link

+1! This feature is critical for efficiency improvement when organizing analytics results

@holgerbrandl
Copy link
Contributor

holgerbrandl commented Sep 29, 2017

In general it would be great if the plugin would simply allow to save an html copy of the script and the inlined outputs.

@duzaichuan
Copy link

+1!

@dwSun
Copy link

dwSun commented May 9, 2018

+1

1 similar comment
@Earthson
Copy link

+1

@rgbkrk
Copy link
Member

rgbkrk commented May 16, 2018

I've labeled this as up-for-grabs because no one is known to be working on this yet there are lots of +1s. If you want to tackle it, please do.

It looks like the API you'd want to use is the Atom ContextMenuManager, likely scoping it to .output-area img (or something similar).

@bridgesra
Copy link

bridgesra commented Jun 8, 2018

if you highlight and run both lines:

plt.plot(data)
plt.savefig(path)

with hydrogen, it will save the .png of the plot in the given path.
When i did the above, executing them line by line it did not save the fig.

@Dirivian
Copy link

Dirivian commented Aug 7, 2018

+1

@kylebarron
Copy link
Contributor

@rgbkrk
Is the transfer of image content to the clipboard a different process than the transfer of text to the clipboard? I.e. is it difficult at all to put onto the clipboard, or is it just not exposed in the UI?

@rgbkrk
Copy link
Member

rgbkrk commented Sep 24, 2018

I think it's an Atom thing we have to somehow expose, based on experience with context menus for Electron.

@kylebarron
Copy link
Contributor

I looked a little into the APIs. It appears that Hydrogen currently uses Atom's clipboard API, which seems to only support writing text and not an image.

Atom's clipboard API seems to be separate from Electron's clipboard API, which does allow for writing an image to the clipboard, but it must be a nativeImage, which seems to only allow PNG or JPG formats.

@SKalt
Copy link

SKalt commented Mar 21, 2019

I was able to get around this by opening the element inspector, selecting the image element, and copying the dataURI to my browser. So long as you have the <img>, you should be able to pass its src into NativeImage.createFromDataUrl to prep the underlying png for export.

@wadethestealth wadethestealth added help wanted Help is desired and removed up for grabs labels Jun 3, 2019
@bertrandcz
Copy link

+1

@jazzlw
Copy link

jazzlw commented Oct 30, 2019

+1 I was very sad to find out that Jupyter didn't have this functionality...

@ttxtea
Copy link

ttxtea commented Nov 26, 2020

+1 Particularly when working with remote kernels copying images to your clipboard would be tremendously helpful.

@mebrunet
Copy link

mebrunet commented Mar 5, 2021

I've been using a hacky work around for this when working on a remote kernel (and so savefig saves the plots on the server).

  1. Open the inspector (cmd-option-i on Mac)
  2. Select the inspect element icon in the top of the inspection pane (icon is a mouse in a box)
  3. Click on the plot you want to save
  4. Right-click the html item/tag that is now highlighted in the inspection pane (should start with <img alt src="...)
  5. Click copy link address
  6. Paste that address into a new browser tab
  7. Save or copy the plot from there

It's really not ideal, but for one-off plots, I find it faster than saving to your remote server and retrieving via scp.

Screen Shot 2021-03-05 at 3 10 08 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature ideas help wanted Help is desired
Projects
None yet
Development

No branches or pull requests