I’m developing my first plugin with UXP and I would like to know if it’s possible to export each layer to a separate file, something like the createRenditions in Adobe UXD?
If it’s not possible, this will be in the photoshop uxp plugin roadmap?
You can definitely go to File --> Export --> Layers to Files through the Photoshop menu. But is that reachable via UXP?
If it isn’t, you could try using the Alchemist plugin to “listen” for the event. Check out @DavideBarranca’s video here: https://www.youtube.com/watch?v=aZn_6X6nvUM - that particular video has some listening and layer commands you may find useful (and all the videos in that series are very helpful!)
After other topic I created, I was trying this listener and layers export in other way and weren’t working, buuuut this way File --> Export --> Layers worked like a charm!
I noticed that the alert error was in Portuguese, the translated message would be:
Error 54: Javascript Exception not caught: Error: Unsupported type in descriptorToObject DescValueType.INTEGERTYPE, line:2455 -> throw (new Error("Unsupported type in descriptorToObject" + t) );
It could be possibly caused by file path since in UXP you need tokens instead and I am not sure if that JSX script accepts it as a path or string data type.
@kerrishotts that is not sure. Because this UXP batchPlay calls ExtendScript. It can pass the path as a string and on the other side, it will convert the string type into a file path type and use it in its own executeAction() …it would be a nice hack
So, Fixing the file path does not change the error message, I tried the following:
const fs = require('uxp').storage.localFileSystem;
let entry = await fs.getFolder();
let token = fs.createSessionToken(entry);
And then changed the filePath to use this token, but the error message is the same. @Jarda said something about the fileType and I think may be it, because the error message changed when I tried to use a string instead of an integer (but I don’t know, just hunches).
Did this ever get solved? I’ve been reticent to ask in my own thread, as this exact question was already asked right here. I still have not figured this out, so I’ve been entirely relying on Adobe’s built-in “generate image assets” feature, which involves lots of regex to follow their formatted layer naming/exporting convention via https://helpx.adobe.com/photoshop/using/generate-assets-layers.html
If explaining the process is too arcane, are there any example UXP scripts that I can look at, which have this functionality built-in? I can just extract code from there.
I would greatly prefer to not have to rely on “generate image assets”. All I’d like to do is understand how to export a layer (or layer group) as a .png.
Are there any example scripts that demonstrate how an image is exported from a .psd file to the hard drive?
I’ve attempted to record via batchPlay, but Alchemist captures none of my exports as recordable events. I’ve searched the UXP documentation for anything regarding “export” but I’ve found nothing, so far.