Skip to content

Instantly share code, notes, and snippets.

View undavide's full-sized avatar

Davide Barranca undavide

View GitHub Profile
@undavide
undavide / DemoGist.jsx
Created June 25, 2015 11:18
Demo Gist for Photoshop Scripting Cookbook
$.writeln("Hello World!");
@undavide
undavide / ToggleScriptingListener.jsx
Created June 25, 2015 11:26
Toggle ScriptingListener Logging
// Credits: Tom Ruark
// Switch OFF ScriptingListener output
var listenerID = stringIDToTypeID("AdobeScriptListener ScriptListener");
var keyLogID = charIDToTypeID('Log ');
var d = new ActionDescriptor;
d.putBoolean(keyLogID, false);
executeAction(listenerID, d, DialogModes.NO);
// Switch ON ScriptingListener output
@undavide
undavide / GetPresetsNames.jsx
Created June 25, 2015 18:33
Get Presets Names
function s(str) { return stringIDToTypeID(str) }
var ref = new ActionReference();
ref.putProperty(s('property'), s('presetManager'));
ref.putEnumerated(s('application'), s('ordinal'), s('targetEnum'));
var desc = executeActionGet(ref).getList(s('presetManager'));
var presetDesc = undefined,
lists = desc.count;
for (var i = 0; i < lists; i++) {
@undavide
undavide / panels102_1.js
Last active March 14, 2018 21:36
Instantiate a CSInterface class
// JS file (panel)
var csInterface = new CSInterface();
@undavide
undavide / panels102_2.js
Last active March 14, 2018 21:36
Run the evalScript method
// JS file (panel)
var csInterface = new CSInterface();
csInterface.evalScript('alert("Hello World!")');
@undavide
undavide / panels102_3.js
Last active March 14, 2018 21:36
Run a JSX function
// JS file (panel)
csInterface.evalScript('addSharpeningForWeb()');
@undavide
undavide / panels102_4.js
Last active March 14, 2018 21:35
JSX function
// JSX file (Photoshop)
function addSharpeningForWeb() {
// ... smart Photoshop scripting code here
}
@undavide
undavide / panels102_5.js
Last active March 14, 2018 21:35
Passing primitive data as a parameter
// JS file (panel)
var sharpeningStrength = 225;
csInterface.evalScript('addSharpeningForWeb(' + sharpeningStrength + ')');
// JSX file (Photoshop)
function addSharpeningForWeb(strength) {
// ... you can now use the strength param here
}
@undavide
undavide / panels201_1.js
Last active April 3, 2018 19:46
Interpolating parameters
// JS file (panel)
var sharpeningStrength = 225,
highlightsProtection = 50,
midtonesProtection = 15,
shadowsProtection = 0,
oldAlgorithm = false,
copyrightString = "© John Doe 2018"
csInterface.evalScript('addSharpeningForWeb(' +
sharpeningStrength + ', ' +
@undavide
undavide / panels201_2.js
Last active April 3, 2018 19:54
Send a JSON obiect as a parameter
// JS file (panel)
var paramObj = {
sharpeningStrength : 225,
protection : {
highlights : 50,
midtones : 15,
shadows : 0,
},
oldAlgorithm : false,
copyrightString : "© Jane Doe 2018"