The "Save as PNG" feature already uses the technique you linked to, but it may require user interaction to complete; you may be prompted to choose whether/where to save the file. It also requires the page to be open in a browser window in the first place.
In the past, I looked into trying to use headless mode for both FireFox and Chrome. Both allow you to pass in a URL and have a screenshot of the page's contents generated without opening any windows or requiring any user interaction. But IIRC, I ran into security issues trying to access local files as well as problems with the screenshots failing or being blank due to WebGL not working in headless mode. The security issues might be solved by serving the files from a simple HTTP server running locally, but I'll have to look into the current state of headless WebGL. I suppose an (incredibly hacky) alternative could be to spin up an HTTP server that takes requests containing PNG data and writes them to disk. For each plot page, launch it in a new, isolated browser process, pass some sort of "docbuild" flag to the page in the querystring, have the page automatically send a request to the server with the output of toDataUrl once its finished rendering its first frame, then kill the browser process. Sit back and enjoy the show as browser windows appear and disappear, and pretend like you're back in the late 90's waging one of those hopeless wars against an unending swarm of pop-up ads :) On Monday, December 7, 2020 at 6:01:58 AM UTC-8 dim...@gmail.com wrote: > On Mon, Dec 7, 2020 at 10:02 AM Eric Gourgoulhon <egourg...@gmail.com> > wrote: > > > > > > > > Le lundi 7 décembre 2020 à 10:57:22 UTC+1, Eric Gourgoulhon a écrit : > >> > >> Le lundi 7 décembre 2020 à 10:26:46 UTC+1, François Bissey a écrit : > >>> > >>> > >>> > >>> > On 7/12/2020, at 10:25 PM, Antonio Rojas <nqn...@gmail.com> wrote: > >>> > > >>> > Is there any reason for not making jsmol optional too? Isn't > three.js the default renderer these days? > >>> > > >>> > >>> three.js still cannot be used to build the doc as far as understand. > >> > >> > >> Indeed, this is currently the major drawback of Sage's three.js viewer: > it cannot generate png images in an automatized way (in interactive mode, > there is no problem: it suffices to click on "Save as PNG" in the three.js > menu). As a consequence, all the 3D plots shown at > https://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/plot3d.html > > are generated with jsmol. A drawback here is that these images do not > correspond to what the end user will get in his Sage session. > > > > > > Moreover these 3d images are static; it would be nice to have (at least > some of) them interactive, as in > > https://doc.sagemath.org/html/en/reference/plot3d/threejs.html > > I am confused now - how on Earth the latter interactive plots were > produced then, if not with threejs used within Sage? > Why can't this technique be used with other plots ? > > It's also not clear why three js cannot be used for non-interactive > png generation, this seems to be a lack of some js code in Sage to > do so rather than anything else, see e.g. > > https://stackoverflow.com/questions/40444995/how-to-convert-render-from-three-js-to-png-file > > Dima > > PS. I'll be teaching an intro to computer graphics course from > mid-January, I'm supposed to become an expert on this stuff > any moment now :-) > > > > > > > Eric. > > > > -- > > You received this message because you are subscribed to the Google > Groups "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to sage-devel+...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sage-devel/c27c7737-3bba-486c-a3a2-32617c14e8dfn%40googlegroups.com > . > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/76689f04-71dc-46b2-a5fe-62af9eb3c077n%40googlegroups.com.