Thanks Timothy, I’ve watched David’s guide as-well now (excellent quality, same for Jarda’s guide I’m amazed)
What seems to be happening, it runs the batchPlay (seems to be succeeding sometimes?), and then just stops with the script. Added a try-catch around my main and didn’t resolve anything, still insta close.
const app = require("photoshop").app;
const core = require("photoshop").core;
const action = require("photoshop").action;
async function actionCommands() {
return await action.batchPlay(
[
{
_obj: "select",
_target: [
{
_ref: "layer",
_name: "Background"
}
],
selectionModifier: {
_enum: "selectionModifierType",
_value: "addToSelection"
},
},
{
_obj: "align",
_target: [
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
using: {
_enum: "alignDistributeSelector",
_value: "ADSCentersH"
},
alignToCanvas: false,
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "align",
_target: [
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
using: {
_enum: "alignDistributeSelector",
_value: "ADSCentersV"
},
alignToCanvas: false,
_options: {
dialogOptions: "dontDisplay"
}
}
],
{
modalBehavior: "execute"
}
);
}
async function align() {
await core.executeAsModal(actionCommands, {"commandName": "Action Commands"});
}
Any clues?
I modified the code Jarda gave me to first select the background, and then centre.
Not selecting the background had the same result, would just insta close.
It doesn’t reach the second “runAction” seen below
await runAction("Image Actions Groot (nobatch)", "Image - INITIAL COPY");
resize(document.activeLayers[0], bigWidth, bigHeight);
// await runAction("Image Actions Groot (nobatch)", "Image - CENTRE");
await align();
await runAction("Image Actions Thumb (nobatch)", "Image - INITIAL COPY");
resize(document.activeLayers[0], thumbWidth, thumbHeight);
await align();