I could say that I got my money’s worth here, using two LLMs to put together a script in ExtendScript which switches the brush’s blend mode from Normal to Multiply and back again. I always wanted to learn more about programmatically extending Photoshop but never had a use for that, up until now.
I wonder: is this in general what LLMs do, creating code hard to understand by me, a layman, or is this output just the way ExtendScript looks like when applied to Photoshop’s engine?
The code below. I am curious: how good is this code at all? Does it rank at all, as anything? I sort of expect a lot of this code to be redundant, as well as having code which does not do anything, but I am nowhere educated enough to even guess.
function toggleBrushBlendMode() {
try {
// Reference the brush tool options
var ref = new ActionReference();
ref.putProperty(charIDToTypeID("Prpr"), stringIDToTypeID("tool"));
ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
var toolDesc = executeActionGet(ref);
if (!toolDesc.hasKey(stringIDToTypeID("currentToolOptions"))) {
throw new Error("No currentToolOptions found.");
}
var options = toolDesc.getObjectValue(stringIDToTypeID("currentToolOptions"));
var currentBlendMode = options.getEnumerationValue(stringIDToTypeID("mode"));
var currentModeStr = typeIDToStringID(currentBlendMode);
// Decide on the new mode
var newMode = (currentModeStr === "normal") ? "multiply" : "normal";
// Set the brush tool options with new blend mode
var desc = new ActionDescriptor();
var toolRef = new ActionReference();
toolRef.putClass(stringIDToTypeID("paintbrushTool"));
desc.putReference(charIDToTypeID("null"), toolRef);
var optionsDesc = new ActionDescriptor();
optionsDesc.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID(newMode));
desc.putObject(charIDToTypeID("T "), stringIDToTypeID("paintbrushTool"), optionsDesc);
executeAction(charIDToTypeID("setd"), desc, DialogModes.NO);
} catch (e) {
alert("Error: " + e.message);
}
}
toggleBrushBlendMode();
What do you think? Is this good enough for a blend mode switch?
I used ChatGPT and Copilot in a sort of back and forth between them, because each single output simply by itself did not work. I was feeding their output back to them, to hopefully get closer to a solution for my actually small problem: I wanted to be able to switch between blend modes at the push of a button.
I expected the script to be a lot shorter than it turned out to be, to be honest, and I expected it to be more easily readable than it is now, if you know what I mean.