Hi, we are trying to save the current document as jpeg/png in the temp folder and then read it as an ArrayBuffer for sending it on the API. Here is our code:
const app = require("photoshop").app;
const fs = await require("uxp").storage.localFileSystem;
const formats = require("uxp").storage.formats;
const currentDocument = app.activeDocument;
const tempFolder = await fs.getTemporaryFolder();
const file = await tempFolder.createFile("test.jpg", { overwrite: true });
console.log(file, "fileToken");
currentDocument.saveAs.jpg(
file,
{
quality: 7,
},
true
);
const arrayBuffer = await file.read({ format: formats.binary });
console.log(arrayBuffer, "arrayBuffer");
We have tried this without the temp folder too. Code for that:
const app = require("photoshop").app;
const fs = await require("uxp").storage.localFileSystem;
const formats = require("uxp").storage.formats;
const currentDocument = app.activeDocument;
const file = await fs.getFileForSaving("test.jpg");
console.log(file, "fileToken");
currentDocument.saveAs.jpg(
file,
{
quality: 7,
},
true
);
const arrayBuffer = await file.read({ format: formats.binary });
console.log(arrayBuffer, "arrayBuffer");
But the issue is that the saveAs.jpg method doesn’t save the file at all. The file token is also generated correctly in both the cases. Just the saveAs method doesn’t create a file on the system.
Our manifest config:
"version": "1.0.0",
"main": "index.html",
"manifestVersion": 4,
"host": {
"app": "PS",
"minVersion": "23.0.0",
"data": {
"apiVersion": 2,
"loadEvent": "use"
}
},
"requiredPermissions": {
"allowCodeGenerationFromStrings": true,
"localFileSystem": "fullAccess"
}
App versions that we are using:
Photoshop: 24.0
UXP dev tools: 1.7.0
Please let me know if you require any more details for the solution.
Thanks in advance.