Skip to content

Instantly share code, notes, and snippets.

@lm913
lm913 / 30758_pre.jsx
Last active December 23, 2015 15:20
Pre-processing script for 30758
/**
* ---Required ps functions---
* psNewPath
*/
var doc = app.activeDocument;
//create the path items
psNewPath("Outline");
psNewPath("Strap");
@lm913
lm913 / DeleteNullPaths.jsx
Last active December 16, 2015 13:56
Script to delete empty paths
var docRef = app.activeDocument;
var numPaths = docRef.pathItems.length;
var pathsLeft = numPaths
if (numPaths > 0){
for (var i = 0; i < pathsLeft; i++){
var pathSelected = docRef.pathItems[i];
if(pathSelected.subPathItems.length==0){
docRef.pathItems[i].remove();
@lm913
lm913 / CountPathPoints.jsx
Last active December 16, 2015 16:17
Script to count path points
var docRef = app.activeDocument;
try{
var numPaths = docRef.pathItems.length;
var countPoints = docRef.pathItems[0].subPathItems[0].pathPoints.length;
if (numPaths > 0){
alert(countPoints);
}
}
@lm913
lm913 / CountPathPointsAvg.jsx
Last active December 16, 2015 16:44
Consistent counting of path points for determining complexity
var docRef = app.activeDocument;
try{
var numPaths = docRef.pathItems.length;
var topPath = docRef.pathItems[0];
var topPathSub = docRef.pathItems[0].subPathItems[0];
if (numPaths > 0){
topPath.makeSelection();
docRef.selection.makeWorkPath(5);
@lm913
lm913 / Test.jsx
Last active December 16, 2015 17:23
Benchmarking script
#target Photoshop
app.bringToFront();
var docRef = app.activeDocument;
var doc = activeDocument;
var Res= 72
var Width= 1000
var Height= 1000
@lm913
lm913 / CanvasSizeCheck.jsx
Last active December 18, 2015 22:06
Check the canvas against given size requirements and makes the necessary adjustments
// enable double clicking
#target photoshop
app.bringToFront();
var doc = activeDocument;
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startDisplayDialogs = app.displayDialogs
var startBgColor = app.backgroundColor
@lm913
lm913 / benchmark.jsx
Last active December 18, 2015 21:53 — forked from kardolus/30425.jsx
Benchmark PhotoShop Actions in Extended Javascript
var folder = 'C:\\LocalStorage'; // resource folder
var benchmarkFile = 'C:\\LocalStorage\\benchmark.csv'; // test results
/**
* The functions you combine in this method will be benchmark tested
* @param fileName - Target file
*/
function psAction(fileName){
psOpenFile(fileName);
psDefaultUnits();
@lm913
lm913 / 32020_Pre.jsx
Last active December 23, 2015 15:38
Pre-process script for 32020
/**
* ---Required ps functions---
* psNewGroup
* psNewPath
* psNewLayer
* psNewMask
* psAdjColourFill
* psApplyImgMask
* psDuplicate
*/
@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;}
}
@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();
}