Skip to main content
Participant
January 22, 2024
Question

Is it possible to batch export as PNG in UXP?

  • January 22, 2024
  • 1 reply
  • 1045 views

Hi all! I'm kinda new to UXP development and need some help with batch exporting. Here's a description of my situation:

My team has PSD files with 2+ artboards. In each artboard, there are multiple text elements in different languages; for example "Title_English", "Title_Spanish", etc.

To export, their workflow is currently:
- Enable just the text element they want.

- Export As -> PNG

- Disable the old text element

- Enable the next text element

- Export As -> PNG

and repeat.

 

I'm trying to write a plugin for them to automate this process. I'm Ok finding the layers that need to be toggled on/off, but I'm struggling to find a way to bring up the "Save As..." panel, and then detecting when the user hits the "Export" button so that the "Save As..." panel can be brought up again with the next layers on. I've tried using Alchemist to detect these events but the only thing that shows up is "Invoke Command: 3443" which is what brings up the "Save As..." window.

 

Thank you in advance for your suggestions, and I'm also open to changing the approach if you think there's a better way to do this 🙂

This topic has been closed for replies.

1 reply

Inspiring
January 23, 2024

What you ask in javascript is very simple Unfortunately in uxp it is a little more complicated when it comes to session tokens. Having said that, you thought of an action and then you use the photoshop batch.

 

I saw you didn't answer
however this opens the save as window

 

document.getElementById("btnPopulate").addEventListener("click", test1);


async function test1() {


Save_As()


}





async function action18() {
    let result;
    let psAction = require("photoshop").action;

    let command = [
        // Save
        {"descriptor": {"_obj":"save"}, "options": {"dialogOptions": "display"}}
    ];
    result = await psAction.batchPlay(command, {});
}

async function Save_As() {
    await require("photoshop").core.executeAsModal(action18, {"commandName": "Action Commands"});
}