There are several ways to do this. One way is to create a transparent field on top (or in front) of an image and group them. Give this group the name "Caption". Then use this script:
export snapshot from group "Caption" to myPictureData as PNG
Now you can create a new image and set the text of the image to myPictureData or save myPictureData to a file.