Hello! Despite it’s weekend I really hope someone is available to respond and help him me to overcome/workaround this urgent problem.
I need to save the activeDocument (PSD, which is saved on local disk) as PNG multiple times (I make different layers visible/invisible).
I tried the code below without success:
var output_file = await out_folder.createFile("test.png");
await psd_doc_ref.save(output_file);
Then I read in some ticket that the file should be unsaved, it was clarifed by @kerrishotts and it was suggested to create a new document, then copy the layers into it.
I tried that way but unfortunately it makes problems in my case as smart object contents were not being copied automatically.
I tried to duplicate the document (to create an unsaved doc) with the code below:
const result = await batchPlay(
[
{
"_obj": "duplicate",
"_target": [
{
"_ref": "document",
"_enum": "ordinal",
"_value": "first"
}
],
"documentID": doc_ref._id,
"_isCommand": true,
"_options": {
"dialogOptions": "dontDisplay"
}
}
],{
"synchronousExecution": false,
"modalBehavior": "fail"
});
}
It seems the duplication works perfect, then I am running this (no success, no error):
while (app.activeDocument._id === psd_doc_ref._id) {
await sleep(500);
}
await app.activeDocument.save(output_file);
Please help to solve the problem it’s very urgent. @Jarda
P. S. I use PS 22.4.2 Release