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

New dom-to-image plugin for saving DOM nodes as an image #8810

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Jermolene
Copy link
Member

The motivation is to be able to save maps generated by Leaflet.js as PNG, JPEG or SVG images, which is not natively supported by Leaflet. This PR uses the library https://github.com/1904labs/dom-to-image-more to provide the underlying functionality.

Copy link

github-actions bot commented Dec 9, 2024

Confirmed: Jermolene has already signed the Contributor License Agreement (see contributing.md)

Copy link

netlify bot commented Dec 9, 2024

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit 41c7948
🔍 Latest deploy log https://app.netlify.com/sites/tiddlywiki-previews/deploys/67668ecec0f10000083d2dda
😎 Deploy Preview https://deploy-preview-8810--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Jermolene added a commit that referenced this pull request Dec 9, 2024
@Jermolene
Copy link
Member Author

Jermolene commented Dec 9, 2024

To try the feature out, visit the preview here, and then scroll down and click the button "Save the screen as an image tiddler". After a second or two, the link to $:/temp/screenshot.png should change to indicate that the tiddler exists. You can then click the link to inspect the screenshot.

image

@pmario
Copy link
Member

pmario commented Dec 9, 2024

Should it be possible to store SVGs. It did not work for me. Is there something special to save SVGs

@Jermolene
Copy link
Member Author

Should it be possible to store SVGs. It did not work for me. Is there something special to save SVGs

Thanks @pmario I've just pushed a fix to saving in SVG format, let me know how you get on.

@pmario
Copy link
Member

pmario commented Dec 10, 2024

It seems to work now. I was just curious, how the SVG code would look like. The resulting SVG is very large, but also very interesting. The resulting code seems to be very verbose. It seems to contain a lot of redundant information, that could probably be optimized. -- but SVG-Optimizer can not handle the code :/

So it would probably be needed to request that feature upstream. -- As I wrote -- I was just curious.

@Jermolene
Copy link
Member Author

It seems to work now. I was just curious, how the SVG code would look like. The resulting SVG is very large, but also very interesting. The resulting code seems to be very verbose. It seems to contain a lot of redundant information, that could probably be optimized. -- but SVG-Optimizer can not handle the code :/

So it would probably be needed to request that feature upstream. -- As I wrote -- I was just curious.

Yes indeed. It is a truly fantastic hack; if you think about it, it is a complete web renderer written in JavaScript that with optimisations based on the host engine. There are some annoying issues with CORS that will frustrate a lot of people, as usual.

One question is whether it is appropriate to bury this functionality within the geospatial plugin. There's no dependency beyond the fact that the functionality is useful when used together. The alternative would be to ship it as a new plugin of its own.

@pmario
Copy link
Member

pmario commented Dec 10, 2024

One question is whether it is appropriate to bury this functionality within the geospatial plugin. There's no dependency beyond the fact that the functionality is useful when used together. The alternative would be to ship it as a new plugin of its own.

hmmm, I think it would make sense as a new plugin. I usually need to make screenshots from tiddlers using an external tool. Usually that's good enough, but it will not allow me to create screenshots, that are longer than one screen size.

This library allows us to create images larger than one screen height.

@Jermolene
Copy link
Member Author

Updated my earlier post to correct the link to the preview

@Jermolene Jermolene changed the title Geospatial Plugin: Add support for saving DOM nodes as an image New dom-to-image plugin for saving DOM nodes as an image Dec 13, 2024
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

Successfully merging this pull request may close these issues.

2 participants