I want to export the current stage as an picture, i.e. exactly what you get when right-clicking the stage and choosing "pic...". However I want to do this programmatically within a block.
There have been solution for this a couple of years ago, but they don't seem to work any more (they produce JavaScript type errors), e.g. search forum for "Save background as file" (I can't post links here).
However, this block is only available in dev mode, so you have to shift-click the Snap! Logo on the top-left corner, click "Switch to dev mode", and you will find this block in the Looks category. Make sure to switch back to user mode afterwards!
Alternatively, you can just drag this block from the post and drop it into the editor, and you'll get the block.
Then, there is a library block in some library that will export a costume, but I don't have time to find it. Libraries are found in the file menu.