Cesium Screenshot service/api

I need the ability to request a jpg of what Cesium renders at specified camera positions.

As Cesium needs WebGL, i am trying to work out my options, and wanted to ask here to see if anyone has done anything similar.

Option 1

run cesium via node (is this possible?) on a machine that has a gpu and somehow access the rendered canvas and return it as a jpg.

Option 2

run a cesiumjs application in. the cloud, and have a separate Node Puppeteer API view the page and return a screenshot.

As these solutions will be hosted in the cloud on linux instances that , as I understand it, won’t have a GPU, I am not sure either will work, has anyone succeeded in achieving this?

I think option 2 is your best bet. CesiumJS can run in NodeJS, because CesiumJS doesn’t require instantiating a Viewer. You can run CesiumJS as a command-line library just to fetch tiles/decode a heightmap etc without ever rendering anything or requiring a browser.

So if you want to get a screenshot you need to run CesiumJS in a browser that supports WebGL so you can render something to a canvas and capture that.