What I’m trying to do
I would like to export a Canvas as a PNG in an automated means. Specifically, when I use the Command “Canvas: Export as Image”, there is a dialog box asking for me to select options, and then a file chooser to choose the file. I would like a way to run the command and pass it in the options I want, along with the filename.
The use-case is I have multiple canvases that I want to embed in other notes. Because embedding a canvas file isn’t fully supported yet (doesn’t look right), I export the canvas to a png, and then embed the png into the note I want. This works well in that it looks good in the note and it when I share my markdown with other markdown services, it works on their systems as well since it’s just a png.
But I hate the ~5 click requirement to do it manually.
- Run the command
- Change an option or two
3/4) Browse to the output directory - Confirm overwrite
So I’d love to have a script/command that I can call that will use the default options I like and that I can specify the file to use so it’s a one-click solution.
Things I have tried
I’ve looked at using the Templatar plugin, and can get it to run the export command, but that simply brings up the modal.
I’ve looked at User Scripts in QuickAdd, which let me run the command directly (same problem as above) or I can access the canvas directly, but don’t know how to convert that to a PNG.
Advanced URI plugin looks like it has some abilities to send parameters with commands, but there are no parameters for the Export as Image command that I can find. I’ve looked around the JS objects in debug tools and couldn’t find anything.
Does anyone know of any api that is available to doing the conversion or calling the command with some parameters?
Thanks for the help!