Skip to content

Instantly share code, notes, and snippets.

#target photoshop
#target estoolkit
app.bringToFront();
var win;
var winResource;
winResource = "dialog { \
orientation: 'column', \
alignChildren: ['fill', 'top'], \
// enable double clicking
#target photoshop
app.bringToFront();
var doc = activeDocument;
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits;
var startTypeUnits = app.preferences.typeUnits;
var startDisplayDialogs = app.displayDialogs;
// enable double clicking
#target photoshop
app.bringToFront();
var doc = activeDocument,
docName = activeDocument.name;
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits,
startTypeUnits = app.preferences.typeUnits,
@lm913
lm913 / psDuplicate.jsx
Created December 23, 2015 15:28
Duplicates a Layer within a pre-processing script
function psDuplicate(sourceName,destName,vis,lock,showHide){
//"HdAl" - Hide All; "RvlA" - Reveal All; "RvlS" - Reveal Selection
var doc = app.activeDocument;
if(doc.activeLayer.isBackgroundLayer){
doc.activeLayer.duplicate();
doc.layers.name = destName; //variable must be string
} else {
doc.layers.getByName(sourceName).duplicate();
@lm913
lm913 / psApplyImgMask.jsx
Created December 23, 2015 15:27
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);
@lm913
lm913 / psAdjColourFill.jsx
Created December 23, 2015 15:27
Creates a Colour Fill Adjustment Layer within a pre-processing script
function psAdjColourFill(layerName,r,g,b){
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
psNewLayer(layerName,null,null,null);
var descACF1 = new ActionDescriptor();
var refACF1 = new ActionReference();
refACF1.putClass(sTID("contentLayer"));
descACF1.putReference(cTID("null"), refACF1);
@lm913
lm913 / psNewMask.jsx
Created December 23, 2015 15:26
Creates a New Mask within a pre-processing script
function psNewMask(showHide,appliedLayer){
//"HdAl" - Hides; "RvlA" - Reveal All; "RvlS" - Reveal Selection
try{
app.activeDocument.activeLayer = doc.artLayers.getByName(appliedLayer); //variable must be string
}
catch(e){
}
cTID = function(s) { return app.charIDToTypeID(s); };
@lm913
lm913 / psNewLayer.jsx
Created December 23, 2015 15:25
Creates a New Layer within a pre-processing script
function psNewLayer(layerName,vis,lock,showHide){
//"HdAl" - Hides; "RvlA" - Reveal All; "RvlS" - Reveal Selection
var doc = app.activeDocument;
if(app.activeDocument.activeLayer.isBackgroundLayer){
app.activeDocument.activeLayer.name = layerName; //variable must be string
} else {
doc.artLayers.add().name = layerName; //variable must be string
}
@lm913
lm913 / psNewPath.jsx
Created December 23, 2015 15:25
Creates a New Path within a pre-preprocessing script
function psNewPath(pathName){
var doc = activeDocument;
try{
doc.pathItems.add(pathName, new Array()); //variable must be string
}
catch(e){
doc.pathItems.add(pathName+" 001", new Array()); //variable must be string
}
doc.pathItems.getByName(pathName).deselect();
}
@lm913
lm913 / psNewGroup.jsx
Created December 23, 2015 15:24
Creates a New Group within a pre-processing script
function psNewGroup(groupName,vis,lock,showHide){
//"HdAl" - Hides; "RvlA" - Reveal All; "RvlS" - Reveal Selection
var doc = activeDocument;
doc.layerSets.add().name = groupName; //variable must be string
if(!showHide) {showHide=null} else {psNewMask(showHide,null);}
if(vis==false) {doc.layerSets.getByName(groupName).visible = vis} else {lock=null;}
if(!lock) {lock=null} else {doc.layerSets.getByName(groupName).allLocked = lock;}
}