Skip to main content
Participant
March 21, 2023
Question

Photoshop UXP Plugin - Open Local File

  • March 21, 2023
  • 1 reply
  • 1424 views

Hello,

 

My wife is an artist and I'm making a custom/private plugin (not for distribution) to queue up files for printing based on her online orders.

 

I have everything working: enter an order number - the order details are loaded and displayed in my plugin. Along with each order item, I have a string such as "D:/Pictures/Alley/ghost-western.jpg"  that corresponds with an art print a customer ordered. How do I instruct photoshop to open "D:/Pictures/Alley/ghost-western.jpg" without having my wife manually navigate to the file?

 

Do I do something like this?
(note: this code doesnt work in my plugin)

const fs = await require('uxp').storage.localFileSystem;
const file =  await fs.getEntryWithUrl("file://D:/Pictures/Alley/ghost-western.jpg");
const app = require("photoshop").app;
app.open(file);

 

This topic has been closed for replies.

1 reply

Stephen Marsh
Community Expert
Community Expert
March 21, 2023

I don't do any UXP, so I can't directly help from experience, but I do have an idea:

 

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

    // Open
    command = {"_obj":"open","documentID":59,"dontRecord":false,"forceNotify":true,"null":{"_kind":"local","_path":"~/Desktop/myFile.jpg"},"template":false};
    result = await psAction.batchPlay([command], {});
}

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

await runModalFunction();

 

Hopefully, you can clean up that code and or extract only what is needed.

 

You could also try this forum if you don't get a workable reply here:

 

https://forums.creativeclouddeveloper.com/