Skip to content

Instantly share code, notes, and snippets.

@yikuansun
Created February 24, 2024 23:16
Show Gist options
  • Save yikuansun/b3dc1345eac5c717d5b07f55dadddb76 to your computer and use it in GitHub Desktop.
Save yikuansun/b3dc1345eac5c717d5b07f55dadddb76 to your computer and use it in GitHub Desktop.
Add image to document synchronously in Photopea
let currentDocument = app.activeDocument;
/*
load in the image as an array buffer - will open in new document
*/
app.activeDocument.activeLayer.copy(true);
app.activeDocument.close();
app.activeDocument = currentDocument;
let newLayer = currentDocument.layers.add();
currentDocument.paste();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment