According to the documentation for the Photopea API, the “script” parameter of the JSON configuration object “should be executed after loading each file (can be long)”
However, when I test the following simple JSON object within the Playground page, it appears that the script is trying to run BEFORE the files have fully loaded:
{
"files": [
"https://www.photopea.com/api/img2/pug.png",
"https://www.photopea.com/api/img2/pug.png"
],
"environment": {
},
"script" : "app.documents[1].rotateCanvas(90);"
}
The script attempts to rotate the canvas of the 2nd document, which presumably fails because the script executes before the 2nd file has loaded.
How, using the API, can I get the script to run only AFTER all the documents have loaded?