I don’t know how the core scripts do it (the screenshot), but currently, developers don’t have access to the API for that. The closest you can do is use ViewportFrames to create a “fake” picture, but that would be extremely tedious. I mean what if you have a lot of things in your scenery? We’d need to clone all that within the picture and put it in a ViewportFrame, and that can get laggy!
For a while, I’d always wanted to create a feature request about this, but I just didn’t know how useful it would be beyond using a camera take a picture. Now that you’ve asked this, I can see that this is a pretty needed feature.