[chrome context menu] Action to save images
Currently there is no way to save images
The added action would increase the usefulness of this package.
@FormalSnake If you have interest in contributing to the Electron project, this would be an approachable first-issue for doing so.
Chromium has a C++ class called content::RenderFrameHost which contains the functionality you're asking for:
https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/render_frame_host.h;l=617-627;drc=61a5359d2a66fc8484ddcad5d7384c98e753f0da
Electron's WebFrameMain API is a JavaScript abstraction of RenderFrameHost. Two methods WebFrameMain.saveImageAt(x, y) and WebFrameMain.copyImageAt(x, y) can be added which call the same methods in RenderFrameHost.
https://github.com/electron/electron/blob/main/shell/browser/api/electron_api_web_frame_main.cc
@FormalSnake If you have interest in contributing to the Electron project, this would be an approachable first-issue for doing so.
Chromium has a C++ class called
content::RenderFrameHostwhich contains the functionality you're asking for: https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/render_frame_host.h;l=617-627;drc=61a5359d2a66fc8484ddcad5d7384c98e753f0daElectron's
WebFrameMainAPI is a JavaScript abstraction ofRenderFrameHost. Two methodsWebFrameMain.saveImageAt(x, y)andWebFrameMain.copyImageAt(x, y)can be added which call the same methods inRenderFrameHost. https://github.com/electron/electron/blob/main/shell/browser/api/electron_api_web_frame_main.cc
Sure, i'll make the issue! But isn't an alternative to use the image address and download that in the background to "simulate" the effect?
But isn't an alternative to use the image address and download that in the background to "simulate" the effect?
That's one possible approach, but will fail in cases where authentication http headers are required or for generated images. The benefit of using the internal methods is that it may also avoid redownloading the image.
makes a lot of sense!
I made the issue, if there are any mistakes please tell me https://github.com/electron/electron/issues/45268
lgtm! If you have the appetite to contribute the code changes as well, the process for building Chromium is fully documented here: https://www.electronjs.org/docs/latest/development/pull-requests
The whole set of changes would only require modifying a few files:
- Document new WebFrameMain methods in the docs which will generate the type definitions:
https://github.com/electron/electron/blob/main/docs/api/web-frame-main.md - Implement
WebFrameMain::SaveImageAtandWebFrameMain::CopyImageAt. Then define JavaScript methods withinWebFrameMain::FillObjectTemplate
https://github.com/electron/electron/blob/main/shell/browser/api/electron_api_web_frame_main.cc
https://github.com/electron/electron/blob/main/shell/browser/api/electron_api_web_frame_main.h - Add tests to ensure images are downloaded and written to clipboard
https://github.com/electron/electron/blob/main/spec/api-web-frame-main-spec.ts
lgtm! If you have the appetite to contribute the code changes as well, the process for building Chromium is fully documented here: https://www.electronjs.org/docs/latest/development/pull-requests
The whole set of changes would only require modifying a few files:
- Document new WebFrameMain methods in the docs which will generate the type definitions: https://github.com/electron/electron/blob/main/docs/api/web-frame-main.md
- Implement
WebFrameMain::SaveImageAtandWebFrameMain::CopyImageAt. Then define JavaScript methods withinWebFrameMain::FillObjectTemplatehttps://github.com/electron/electron/blob/main/shell/browser/api/electron_api_web_frame_main.cc https://github.com/electron/electron/blob/main/shell/browser/api/electron_api_web_frame_main.h- Add tests to ensure images are downloaded and written to clipboard https://github.com/electron/electron/blob/main/spec/api-web-frame-main-spec.ts
I would love to, but c++ development is not really my cup of tea. I will give it a try but I cannot guarantee anything
I would love to, but c++ development is not really my cup of tea. I will give it a try but I cannot guarantee anything
The most painful aspect will be the initial build of Chromium (>35 million lines of code!). Happy to help if you get stuck at any point.
I am stuck with building it :(
I do not have enough storage on my laptop, and I have no extra drives sadly
and forgot to mention that i also have some issues with build-tools and nix lol
I do not have enough storage on my laptop, and I have no extra drives sadly
Ah, that is a requirement unfortunately. It's close to 100GB between the source+build files and the git cache on my local disk.
so apparently copyImageAt is already an existing function, so maybe that can be added for now before they add the saveImageAt (if that happens) https://github.com/electron/electron/issues/45268#issuecomment-2603293584