Copy link to clipboard
Copied
With my uxp plugin I call the native Photoshop script “load files into stack”. I can successfully load it from UI and can select layers to be loaded into stack. Unfortunately the script stops after the first file has been loaded into stack albeit I have selected more than 1 file to be loaded into stack. Currently, there seems to be no direct Photoshop API feature that returns the quantity of selected files or that waits automatically for all files to load when using the native “load files into stack” command. Has someone found a solution to overcome this problem or can you suggest a solution? Here is the code of my LoadFilesIntoStack.js file:
import { core, action } from "photoshop";
const { executeAsModal } = core;
const { batchPlay } = action;
console.log("LoadFilesIntoStack.js loaded");
async function loadFilesIntoStack() {
console.log("Executing 'Load Files into Stack'...");
try {
const result = await batchPlay(
[
{
_obj: "AdobeScriptAutomation Scripts", // Corrected object name
javaScriptName: "Load Files into Stack...", // Corrected script name
javaScriptMessage: "undefined", // This matches Alchemist output
_isCommand: false, // This was also part of Alchemist output
_options: {
dialogOptions: "display" // Ensures the UI is shown
}
}
],
{
synchronousExecution: true,
modalBehavior: "execute"
}
);
console.log("Files loaded into stack successfully.", result);
return result; // Capture and return result
} catch (error) {
console.error("Error executing 'Load Files into Stack':", error);
}
}
async function runModalFunction() {
try {
return await executeAsModal(loadFilesIntoStack, { commandName: "Load Files into Stack" });
} catch (error) {
console.error("Error running modal function:", error);
}
}
export default runModalFunction;
Thank you for your quick response. I suspect a runtime error which I can't explain since the script "Load Files into Stack" started loading files into stack but got stuck after the first file was loaded into a layer. I then set a delay function which helped. Now the script runs like charm. Still don't now why this works... but it does. Thank you all again for your support.
Copy link to clipboard
Copied
Adobe need to update all of their old .JSX scripts for. .PSJS or UXP panels. I believe it's one technology or the other as they can't be mixed.
Copy link to clipboard
Copied
I created a small focus stacking panel with a donation option Here is the link https://sites.google.com/view/openpaneluxp/focus-stacking
As you can see from the video I did not use the option to open the dialog box, I tried to do it all automatically. The only problem I had was loading the nef - raw files in photoshop, using uxp opened the nef in photoshop and not in camera raw, so I opted to insert a . Jsx file inside the panel. I looked around and I did not find any documentation for this. Unfortunately some things in uxp still need to be perfected and javascript programming is still needed I'm not at home now, after I get back I'll take a look at your script and if I can help you I'll do it willingly.
see if this works for you
async function stack() {
let result;
let psAction = require("photoshop").action;
let command = [
// Script
{"descriptor": {"_obj":"AdobeScriptAutomation Scripts","javaScriptName":"Carica file in serie..."}, "options": {"dialogOptions": "display"}}
];
result = await psAction.batchPlay(command, {});
}
async function FunctionStack() {
await require("photoshop").core.executeAsModal(stack, {"commandName": "Action Commands"});
}
await FunctionStack();
Copy link to clipboard
Copied
Thank you for your quick response. I suspect a runtime error which I can't explain since the script "Load Files into Stack" started loading files into stack but got stuck after the first file was loaded into a layer. I then set a delay function which helped. Now the script runs like charm. Still don't now why this works... but it does. Thank you all again for your support.
Copy link to clipboard
Copied
That's great! It reminds me of AppleScript having the ability to either run JSX "inline" or by calling an external JSX file to accomplish tasks outside of the AS DOM.
Copy link to clipboard
Copied
Opps, The script you posted doesn't work for me?
Copy link to clipboard
Copied
Hi Ciccillotto,
Just to make it more clear to you how I'm using this script... The script is in a separate js-file file. I have an index.html file for the sp-picker. I'm using to call the script. This is achieved by an event listener in main.js to call the native modal Photoshop script 'Load Files into Stack". If it doesn't work for you it's probably because of how you call the script.
Copy link to clipboard
Copied
Thanks for the replying.
Copy link to clipboard
Copied
Hi! I have this problem too, I have zero idea how to fix it. I'm on a PC. And this happens to me as well, I try to load files into stack to make gifs and after the first one opens, the screen loads and then just gets rid of it completely. I don't know anything about scripts. Please help.
Copy link to clipboard
Copied
Hi! I have this problem too, I have zero idea how to fix it. I'm on a PC. And this happens to me as well, I try to load files into stack to make gifs and after the first one opens, the screen loads and then just gets rid of it completely. I don't know anything about scripts. Please help.
By @theladyash
If you know nothing about scripts and are not calling the legacy ExtendScript code from the new UXP framework, then you would be best to create a new topic as your situation isn't the same and piggybacking onto this topic will provide less visibility and limit the potential help you may receive.
Edit: You could try some simpler, alternative stacking scripts:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/combining-tiffs/m-p/13475955
https://community.adobe.com/t5/photoshop-ecosystem-discussions/layers-creating-layers/td-p/13252109
Copy link to clipboard
Copied
If you can open a new post it's better, If it's for uxp I posted a script above, see if it works, If you already have a script post it and we'll see where the error is.