Skip to content

Instantly share code, notes, and snippets.

@ashikka
Created December 31, 2021 09:11
Show Gist options
  • Select an option

  • Save ashikka/f5411e3470e3dc4f15d1ae5a956d5791 to your computer and use it in GitHub Desktop.

Select an option

Save ashikka/f5411e3470e3dc4f15d1ae5a956d5791 to your computer and use it in GitHub Desktop.
async function downloadIt(link) {
const image = await fetch(link);
console.log(link);
try {
const img = await image.arrayBuffer();
const file = await fs.getFileForSaving("image.png");
await file.write(img);
const currentDocument = app.activeDocument;
const newDocument = await app.open(file);
if (currentDocument) {
await newDocument.activeLayers[0].duplicate(currentDocument);
await newDocument.close();
}
} catch (e) {
console.log(e);
}
if (!file) {
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment