Copy link to clipboard
Copied
I've been a professional editor/retoucher for photographers for the past three years. I use a lot of actions, but I've never branched into scripts until now. I'm trying to refine my workflow and scripts seem like the next logical step.
I do a lot of interiors work, which is basically manual HDR. Here's my current build process, which I'd love to find a way to script. I tried to be very clear, but let me know if this needs fleshing out. I'm using Photoshop CS5.
1. Pull up bracketed, color-corrected TIFFs in Bridge.
2. Re-order as needed, with main exposure at the bottom. Click "Tools" > "Photoshop" > "Load as Photoshop layers" to get a PSD with layers in correct order and main exposure as background (base) layer.
3. Manually go through each layer and add a Hide All layer mask to every layer except the background layer.
4. Save as a PSD, using the original name of the background layer as the filename. To do this I just copy the layer name (example.tiff), paste in the Save dialog and then use the dropdown menu to select PSD (thus saving as example.psd).
I'm hoping to automate steps 3 and 4 as they are the most time consuming for me. Any input is appreciated!!
Thanks again.
Yes your change is good. That way the last layer won't have a mask applied. I wasn't sure if you wanted that, but put in the check for the background layer.
As far as saving, what file format do you want to save to? Here's how I save a psd:
...
var docRef = activeDocument
var doneFolder = new Folder('/c/photos/')
var layerName = docRef.activeLayer.name
var psdOptions = new PhotoshopSaveOptions();
psdOptions.layers = true;
app.displayDialogs = DialogModes.ALL;//include this line if you want the dialog
Copy link to clipboard
Copied
That sets the active layer - I confirmed it with an alert. It still doesn't run the fuction layerMask on the active layer set by the script. It only runs the function on the layer selected in Photoshop on the layers palette.
I've noticed that none of the functions written like the one I pasted above work when the active layer is set by code earlier in the script.
Copy link to clipboard
Copied
Sorry, I'm just not getting it...
#target photoshop
activeDocument.activeLayer = activeDocument.layerSets["Group 1"].layers["FOO"];
layerMask();
function layerMask() {
var idmake = stringIDToTypeID("make");
var desc6898 = new ActionDescriptor();
var idnew = stringIDToTypeID("new");
var idchannel = stringIDToTypeID("channel");
desc6898.putClass(idnew, idchannel);
var idat = stringIDToTypeID("at");
var ref412 = new ActionReference();
var idmask = stringIDToTypeID("mask");
ref412.putEnumerated(idchannel, idchannel, idmask);
desc6898.putReference(idat, ref412);
var idusing = stringIDToTypeID("using");
var iduserMaskEnabled = stringIDToTypeID("userMaskEnabled");
var idrevealAll = stringIDToTypeID("revealAll"); // ("hideAll")
desc6898.putEnumerated(idusing, iduserMaskEnabled, idrevealAll); // idhideAll
executeAction(idmake, desc6898, DialogModes.NO);
}
Copy link to clipboard
Copied
Yeah looks like it's working for you. I'm not sure why I get different behavior from it. I'll try resetting Photoshop preferences and see if that clears it up. Thanks for the help!
Copy link to clipboard
Copied
I got rid of everything but the script you pasted here and it worked! It looks like the problem in my original script is somehwere around this:
var lyrAct = activeDocument.activeLayer;
Maybe I have been using that incorrectly?