Heya all, I’m working on a plugin that remixes a bunch of layer combinations, merges them down, and exports them automatically.
I previously had this working fine in old school photoshop plugin code, but I’m really struggling to get the exporting to work in UXP.
I’m trying to save to the DataFolder, which according to the documentation does not require user input.
(As I’m trying to export hundreds of files.)
But the save batch is just giving me a save dialog with a default location.
It is worth noting that the Document that this is being done is has not been saved before, as I’m using doucment.duplicate() to speed up my workflow. Could this be a problem?
Any help or pointers in the right direction would be useful!
My code:
async function savePNG(fileName) {
var saveFolder = await require("uxp").storage.localFileSystem.getDataFolder();
var saveFile = await saveFolder.createFile(fileName+".png");
console.log(saveFile.nativePath);
const saveFileToken = await require("uxp").storage.localFileSystem.createSessionToken(saveFile);
await modalBatchPlay(
[
{
"_obj": "save",
"as": {
"_obj": "PNGFormat",
"method": {
"_enum": "PNGMethod",
"_value": "quick"
},
"PNGInterlaceType": {
"_enum": "PNGInterlaceType",
"_value": "PNGInterlaceNone"
},
"PNGFilter": {
"_enum": "PNGFilter",
"_value": "PNGFilterAdaptive"
},
"compression": 6
},
"in": {
"_path": saveFileToken,
"_kind": "local"
},
"saveStage": {
"_enum": "saveStageType",
"_value": "saveBegin"
},
"_isCommand": false,
"_options": {
"dialogOptions": "dontDisplay"
}
}
], {
"synchronousExecution": false
});
}