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

nativeImage.createFromURL(url) #19031

Closed
3 tasks done
whitecrownclown opened this issue Jun 28, 2019 · 3 comments
Closed
3 tasks done

nativeImage.createFromURL(url) #19031

whitecrownclown opened this issue Jun 28, 2019 · 3 comments

Comments

@whitecrownclown
Copy link

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem Description

I would like to be able to implement a Copy Image feature in my app.

Right now, i cannot do this without first downloading the image and doing
nativeImage.createFromBuffer(buffer) or doing nativeImage.createFromPath(path) if the image is on the filesystem. Ideally this would also work with the file protocol.

Adding support for webp would be great since right now you'd have to convert the downloaded image into a format supported by nativeImage in order to copy it to the clipboard.

Proposed Solution

Add a new nativeImage method, nativeImage.createFromURL(url) that downloads the image from the provided url and returns a NativeImage.

Alternatives Considered

None.

Additional Information

This can be done in app code, however having it in electron would greatly simplify this process.
More details: sindresorhus/electron-context-menu#79

Thank you!

@MarshallOfSound
Copy link
Member

For context menus you definitely don't need to download the image and create a nativeImage.

Just use https://electronjs.org/docs/api/web-contents#contentscopyimageatx-y to copy the image where the context menu was triggered

@xadamxk
Copy link

xadamxk commented Jun 6, 2021

Running into a scenario where I could use this.
Instead I have to download an image, convert to buffer, and load the native image that way...

@redspider926
Copy link

MarshallOfSound, I am interested in your suggestion.
Can I use the webcontent for touchbar button icon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants