Skip to content

Instantly share code, notes, and snippets.

@lm913
Created December 23, 2015 15:27
Show Gist options
  • Save lm913/00660da81952f7bf9c05 to your computer and use it in GitHub Desktop.
Save lm913/00660da81952f7bf9c05 to your computer and use it in GitHub Desktop.
Uses Apply Image on a Mask within a pre-preprocessing script
function psApplyImgMask(sourceName,destName){
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
app.activeDocument.activeLayer = doc.artLayers.getByName(destName); //variable must be string
var descAIM1 = new ActionDescriptor();
var refAIM1 = new ActionReference();
refAIM1.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("Msk "));
descAIM1.putReference(cTID("null"), refAIM1);
descAIM1.putBoolean(cTID("MkVs"), false);
executeAction(cTID("slct"), descAIM1, DialogModes.NO);
var descAIM2 = new ActionDescriptor();
var descAIM3 = new ActionDescriptor();
var refAIM2 = new ActionReference();
refAIM2.putEnumerated(cTID("Chnl"), cTID("Chnl"), cTID("RGB "));
refAIM2.putName(cTID("Lyr "), sourceName); //variable must be string
descAIM3.putReference(cTID("T "), refAIM2);
descAIM3.putBoolean(cTID("Invr"), true);
descAIM3.putBoolean(cTID("PrsT"), true);
descAIM2.putObject(cTID("With"), cTID("Clcl"), descAIM3);
executeAction(cTID("AppI"), descAIM2, DialogModes.NO);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment