Adobe Photoshop Scripting - Adobe.js | JavaScript: Behavioral Layer

Standards Based Development

Photoshop plugins are .8bf files.. Afer you download the plug-in, place it in the presets > plugin-ins folder of your Photoshop's installation folder. Creating a folder for your plug-in(s) will help with organization. The Works The Works 3.2 : A collection of 8 plug-in filter sets for use with Adobe Photoshop or compatible host applications (32-bit hosts only. Please note these filters will NOT run under 64-bit versions of CS5 or CS6). Originally created back in the 90's, these filters have been updated several times and converted into a number of different versions. They provide the user with a base of very simple effects that can be handy on a regular basis. Photo-Plugins Shear - After Effects Shear Effect Converted to Photoshop Plug-in Vanderlee's Plug-ins Filter Forge Photoshop Plug-ins Freepacks Filters for Photoshop and After Effects Free Plugins Windows Icon and Windows Cursor Image Format Support Plug-in DepthDither provides color dither for Photoshop when display isn't true color. virtualPhotographer and virtualStudio Plug-ins Free AAA 8bf Plugins for Photo Editors (Windows Only Free Plug-ins | FlamingPear 8bf Filter Plug-ins http://www.autofx.com/freeplugins/dreamyphoto.asp?id=4"> Outliner - Easy Image Contouring Greyscaler and Iridescent Water Ripples Plug-in Filter Free Grayscale Masks for Photo Edge Effects RedField Plugins Download Page - Special Effects for Graphic Designers Sterogram Lab Filter v1.0 FilterMeister (fm) is a plug-in for Photohshop compatible graphics programs with the abitlity to create professional plug-in filters which can be distributed on a royalty-free basis.

Mosaic Toolkit Version 2.55 and the Illumination Fix Toolkit Version 1.7 Plug-ins Smart Refinement Filter Mehdi Plugins - Free Plugins for Photoshop and any Compatible Software 3d Shadow Photoshop Plug-in xero-graphics.co.uk

Photoshop Dev

Photoshop Flash Panels

Flash Panels are available at the Photoshop Exchange for cs4+.

ExtendScript ToolKit (aka ESTK)

Adobe Configurator

Adobe Configurator can be used to make panels (palettes) in cs4+; Adobe air must be installed to use Adobe Configurator.

Extension Manager ships natively with cs4, to view:

  1. go to "Start -> All Programs -> Adobe"
  2. Double click Tools-Explod.mpx -> Adobe Extension Manager cs4 will open automatically
  3. Accept Disclaimer
  4. Verify Extension Manager has "All Tools" extension enabled for Photoshop cs4

Fire up Photoshop and head to Window > Extensions > All Tools and the panel will be visible.

Note: it's common for new panels do not work after installation; Photoshop took a note from Windows playbook here...restart Photoshop and the panel should work.

All panel icons are functional; they are links to the tool they represent.

Photoshop File Types

  • .png - Portable Network Graphics
  • .psd - Photoshop Document
  • .atn - Action Script
  • .csh - Custom Shapes
  • .abr - Brushes
  • .pat - Patterns
  • .jsx - Scripts
  • .asl - Styles
  • .aco - Color Swatch
  • .acb - Color Book & Pantone
  • .shc - Contour
  • .acv - Curve
  • .eap - Exposure Profiles
  • .grd - Gradients
  • .hsl - Hue & Saturation Levels

Comm

Comm http://www.photoshoptechniques.com/forumdisplay.php?83-Scripting-amp-Automation&s=82bc6edd610a7d8d582ff0311fc4e688">Photoshop Scripting & Automation Forum - Photoshop Techniques

Collection of the Best PhotoShop Articles Ever

Articles http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=4737&fileID=4408">GPS Data panel for File Info dialog in Photoshop CS5 - custom File Info panel that displays Exif GPS metadata (Photoshop CS5, Bridge CS5, Fireworks, Flash, Illustrator, and InDesign).

http://www.ps-scripts.com/bb/viewtopic.php?f=2&t=5454&sid=c029bc0c11a064a8410a7bd4c4e7334f">Autohotkey to Open Image in Any Browser http://www.ps-scripts.com/bb/viewtopic.php?f=10&t=4074&sid=c029bc0c11a064a8410a7bd4c4e7334f">ESTK Documentation - script adds a new Menu in ExtendScript Toolkit providing documentation access with a list of all chm, pdf and txt files in the specified folder. http://photoshopnews.com/2005/05/19/adding-photoshopnews-rss-to-bridge-center/">Adding Photoshopnews rss to Bridge Center http://www.tranberry.com/photoshop/photoshop_scripting/index.html">Photoshop Scripting Using JavaScript http://www.pcpix.com/Photoshop/">Scripting Photoshop CS with C# http://www.mouseprints.net/old/dpr/Action_Enhanced_via_Scripted_Photoshop_Functions.txt http://www.mouseprints.net/old/dpr/Sample_Actions.txt http://www.thelightsright.com/TLRVideo_ActionBasicsPt6">Saving Photoshop Actions as Text Files https://code.google.com/p/srgb/downloads/detail?name=AdobeFonts.7z">Adobe document detection font and packaging tools (open source free unlimited use) Code Snippets - PS-Scripts Sublime Text 2 ExtendScript Photoshop Build Package

Targeting Photoshop with JavaScript/ExtendScript

Photoshop cs2 added support for a new file type: .jsx; This new extension can be utilized for targeting a specific Creative Suite Application (Photoshop, Illustrator, etc.) to run a script...or scripts :). The example below specifically targets Photoshop, you can see the call in the first line of non-commented out JavaScript:


// enable double clicking from macintosh finder
// enable double clicking from windows explorer
#target photoshop

Double-clicking on the script shown above will now result in Photoshop automatically running the script, including waking Photoshop up to run the script if it is not already running.

This workflow enabled the scripts author to add ExtendScripts to the OS X dock, making the scripts accessible within a single click, and preventing the author from going back to the OS finder in order to launch them.

Note: if a Creative Suite Application is not targeted in the ExtendScript, .jsx files will open with Adobe's ExtendScript Toolkit.

Targeting Photoshop with a Script

Photoshop Scripting using JavaScript XBatch Photoshop Batch Processor

Photoshops Batch Processor (Automation tool) and ImageProcessor script are extremely powerful, however, even combined they do not offer this feature: the ability to run the batch processors on a source image tree and create a target image tree with the same folder hiearchy. XBatch is a Photoshop Batch Processor that adds this functionality to Photoshop.

The elements of XBatch's ui are faily easy to grasp:

  • Source Directory (folder): here are the images that you would like to process
  • Target Directory (folder): here is where you want the processed images to be stored
  • Action Set: the set where the action resides you want to use
  • Action: name of the action you want to use

Note: the optional use a a script is not that obvious and many users may not even need this option.

Note: there are many things that can only be done using scripts and not actions; assume you flattened an image (can be done using actions) but there are still some alpha channels left; clearing the alpha channels off cannot be performed easily in any action. But there are scripts that can do this; there's actually an ExtendScript included in the XBatch demo that does exactly this.

Note: scripts work inside actions in Adobe JavaScript; the reason we are not implementing XBatch this way is because XBatch is itself a script, and scripts inside actions used from scripts do not work. This is also the reasoning behind adding the option to run a script before the actions are called.

Photoshop

Photoshop Tools

Script Listener

Script Listener is a Photoshop plug-in that records actions as JavaScript (or VBScript)..look up The Script Listener Plug-in in cs6 scripting guide pdf.

Script Listener plug-in for cs6.

Installing Photoshop ScriptListener Plug-

To install the ScriptingListener Plug-in:

On a Mac:
  1. Unzip Scripting Plug-In Release.dmg.
  2. After you unzip the package, you will see three folders: Documents, Sample Scripts and Utilities. Drag the Utilities folders to the Applications\Adobe Photoshop CS6\Plug-ins\ folder.
  3. Note: Alternately, you can create a new "Scripting" folder inside the Plug-ins folder and drag the contents of the package there.
Win 32 bit
  1. Unzip the package Scripting_Plug-In.zip.
  2. Drag the Scripting_Win32 folder to the following location:
  3. C:\Program Files (x86)\Adobe\Adobe Photoshop CS6\Plug-ins\...
Win 64 bit
  1. Unzip the package Scripting_Plug-In.zip.
  2. Drag the Scripting_Win64 folder to the following location:
  3. C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Plug-ins\..
Photoshop Object Model Diagram Photoshop Object Model Diagram

xtools

xtools is a JavaScript toolkit for Photoshop.

Photoshop References and Examples

Photoshop Community ?!?!?!!? DO YOU NEED THIS OR JUST PUT UNDER REFERENCES AND EXAMPLES?

Golden Crop Script: the ultimate cropping solution for Photoshop. Golden Crop Script is a script written in JavaScript language using Adobe® Photoshop® object model. It was designed to help cropping pictures according to some composition rules. Besides that, you can rotate and extend canvas using (nearly) non-destructive methods.

Golden Crop Script has the following features:

  • Rule of Thirds
  • Diagonal Rule
  • Golden Spiral
  • Golden Rule
  • Golden Triangle
  • Crop
  • Extend Canvas
  • Aspect Ratio
  • Rotate
  • Continue From Group
  • Thickness Control
  • Custom Colors
  • Configurable
  • Auto Pop Background
  • Non-Destructive
  • Inter-Active
  • Free

pixelmeasure is a Photoshop script for adding pixel measurements to mockups.

Photoshop Conditional Action Script

html Sample Panel

html Sample Panel, created with Adobe Configurator 3.1.1, illustrates how to create a panel that uses the new HTML Widget. It uses the new scripting features and demonstrates how to interact with Photoshop CS6 through its JavaScript API.

Adobe Configurator 3.1 introduces a new scripting feature, which is available through the HTML Widget. You can now customize your panel extensively by including an HTML Widget with HTML and JavaScript code.

HTML code can integrate popular JavaScript libraries such as JQuery, in order to enrich the user experience.

The HTML Widget has also been enhanced to detect and respond to changes in the Photoshop color theme. You can provide a light and a dark version of your panel, so that it will match the rest of the Photoshop interface when the user switches themes.

Export Layers as Files with layernames

export-layers-to-files.jsx is a an Adobe Photoshop JavaScript ExtendScript that exports every layer in a Photoshop document as a file; Photoshop's default script "Export Layers to Files" does exactly what export-layers-to-files.jsx, except that it composes the filename using prefix + number + layer name; all we require/desire is the layer name. Since "Export Layers to Files.jsx" is similar to what we desire, and we already have it, lets edit it; go to your Adobe Creative Suite directory located somewhere on your boxes directory; in Mac/OS X (first) and Windows you should see something similar:


// mac
/Applications/Adobe/Adobe\ Photoshop\ CS4/Presets/Scripts/
// win
C:\Program Files\Adobe\Adobe Photoshop CS3\Presets\Scripts

Navigate to Adobe's directory on your box, continue navigating to "Scripts" directory and open Export Layers To Files.jsx. Once its open, search for "fileNameBody +=" and edit the JavaScript, like so:


var fileNameBody = fileNamePrefix;
fileNameBody += "_" + zeroSuppress(1, 4);
fileNameBody += "_" + layerName;

the code (above) to the JavaScript ExtendScript code here:


var fileNameBody = fileNamePrefix;
fileNameBody += layerName;

Note: it is imperative that you ensure that there are no duplicate layernames; otherwise the script will overwrite these files.

Exporting Layers as Files with Layernames and Photoshop on the Server

Adobe Photoshop: Step By Step Guide to Using JSX and Running Photoshop from a Webpage Scripting Gallery Adobe Photoshop JSX Web Server

Trigger .jsx via Keyboard Shortcuts

  1. Locate Actions Palette; if it is not visible, choose from the menu Window > Actions
  2. Click "Create New Action"
  3. Name the Action and select the Keyboard Shortcut
  4. Click Record to Begin Recording the Action
  5. Then in the New Action dialog, point the name of the script to be run in the Name input
  6. Select the desired function key; literally will run the selected ExtendScript on keypress
  7. Now Select "Insert Menu Item" in the Actions Palette fly-out-menu
  8. This should cause the "Insert Menu Item" dialog to appear
  9. Go to the "File" menu and navigate to the script that you want to run; Choose: "File" > "Scripts" > "scriptname.js"
  10. Click "OK"
  11. Stop Recording the Action by clicking "Stop Playing/Recording" button on the Actions Palette.

Note: FINISHED! Now, anytime the key that you chose to be linked to this Action is pressed while Photoshop is running, Photoshop will run the script.

Note: to edit this shortcut or others, double-click the action or choose "Action Options" from the Actions Palette fly6out menu.

Scripting Gallery (sourceforge) is a lightweight and easy to use VBScript for Photoshop, automating the task of preparing images for publication them in (web-)gallery.

Scripting Gallery Home

ps-scripts

The PhotoShop Scripts project is a catch-all for several toolkits and scripts that have been developed to facilitate the use of JavaScript for scripting Photoshop and other Adobe Creative Suite applications.

Export Groups to Files in Photoshop

Photoshop cs5 doesn't allow exporting layers with groups (folders); the following ExtendScript will export all groups to high quality pngs:


#target photoshop
function main(){
if(!documents.length) return;
var doc = activeDocument;
var oldPath = activeDocument.path;
for(var a=0;a<doc.layerSets.length;a++){
activeDocument.activeLayer = activeDocument.layers.getByName(doc.layerSets[a].name);
dupLayers();
activeDocument.mergeVisibleLayers();
activeDocument.trim(TrimType.TRANSPARENT,true,true,true,true);
var saveFile= File(oldPath +"/"+doc.layerSets[a].name +".png");
SavePNG(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
    }
}
main();
function dupLayers() { 
    var desc143 = new ActionDescriptor();
        var ref73 = new ActionReference();
        ref73.putClass( charIDToTypeID('Dcmn') );
    desc143.putReference( charIDToTypeID('null'), ref73 );
    desc143.putString( charIDToTypeID('Nm  '), activeDocument.activeLayer.name );
        var ref74 = new ActionReference();
        ref74.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc143.putReference( charIDToTypeID('Usng'), ref74 );
    executeAction( charIDToTypeID('Mk  '), desc143, DialogModes.NO );
};
function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb; 
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false; 
pngOpts.transparency = true; 
pngOpts.interlaced = false; 
pngOpts.quality = 100;
activeDocument.exportDocument(new File(saveFile),ExportType.SAVEFORWEB,pngOpts); 
}

How to Run ps-export-groups-to-files.jsx

  1. Copy the script and save it as ".jsx" file type; JavaScript ExtendScript (aka Adobe JavaScript).
  2. In Photoshop head to the following menu item: File > Scripts > Browse...
  3. Select the .jsx file in the file browser.

Photoshop will now export all groups to files, saving the files in the same directory the .psd is located in.

Note: Known Limitations: empty groups give back an error message and stop the exporting process; also, built for only cs5 and up.

Photoshop Layer Export Tool for Normal iPhone Graphics and Retina Display Graphics; Photoshop Export Tool that allows the exportation of all 6 iPhone icon files from a 512x512 image; Retina Display Compatible.

Scripts for Adobe Photoshop

Dynamic Script.jsx

Dynamic Script.jsx is a very basic script making it easy to test a few lines of JavaScript within Photoshop.

Super Export.jsx

Super Export.jsx is a script allowing for the saving of parts of a PSD as separate cropped files by carefully naming the Photoshop layers. For example, if you name a layer "background.jpg" and execute this script, that layer will be saved and all other layers will be hidden.

Installing .jsx Photoshop Scripts

"Installing" .jsx Photoshop scripts is an odd way of saying that you need to literally drop the script(s) into Photoshop's scripts directory on your box. Below are two examples of typical script directory structures, the first being Mac/OS X and the latter being Windows.


MAC:
/Applications/Adobe Photoshop CS4/Presets/Scripts
PC:
c:\program files\Adobe Photoshop CS4\Presets\Scripts

For this example, let's pretend I'm on OS X; look back at our paths and its a no-brainer: the easiest route for accomplishment is to copy "Super Export.jsx" to our Max OS X directory:


/Applications/Adobe Photoshop CS4/Presets/Scripts/Super Export.jsx

Once you restart Photoshop, a new menu item will show up in the menu File > Scripts > Super Export. Super Export ).......I would imagine that means go ahead and reboot your box? Post reboot, the menu File > Scripts > Super Export should appear.

click on the new menu item ("Super Export") and the script will run.

Creating Keyboard Shortcuts

Once the JSX script file has been created, it is then possible to create a keyboard shortcut (for this example we are using [F5]) to run the JSX script automatically. The four steps listed below explain exactly how to map a JavaScript/ExtendScript file to a keyboard shortcut:

  1. 1) Choose Edit > Keyboard Shortcuts...
  2. 2) Highlight "Super Export" under File > Scripts
  3. 3) Click under the 'Shortcut' column and type the [F5] key (or whatever you want)
  4. 4) If there are conflicts, choose 'Accept ' Continue', otherwise choose 'Accept'

You can also have scripts in subfolders of this directory, so if you're familiar with GIT, want all my scripts, and want easy access to updates you could clone: git@github.com:bendytree/Photoshop-Scripts.git to /Applications/Adobe Photoshop CS4/Presets/Scripts/BendyTree; whenever an update is

wanted/needed/, just do a 'git pull' from that directory. Photoshop gracefully ignores non .jsx files (like .gitignore and readme).

Dynamic Server-Side Image Creation with Photoshop and JSX Process Flow Chart
Dynamic Server-Side Image Creation with Photoshop and JSX Process Flow Chart

CSS3Ps - free cloud based photoshop plugin that converts your layers to css3.

Using 'include' to Reference External Scripts in Photoshop

It's possible to move all of your code into an external .js file by utilizing an 'include' to reference the .js file, keeping the script neat and tidy and following similiarily to the separation of concerns approach practiced by standardistas. The following example and instructions show exactly how to accomplish this:


// create our function:
function makeSlice() {
var id14 = charIDToTypeID( "Mk  " );
  var desc5 = new ActionDescriptor();
  var id15 = charIDToTypeID( "null" );
	var ref2 = new ActionReference();
	var id16 = stringIDToTypeID( "slice" );
	ref2.putClass( id16 );
  desc5.putReference( id15, ref2 );
  var id17 = charIDToTypeID( "Usng" );
	var desc6 = new ActionDescriptor();
	var id18 = charIDToTypeID( "Type" );
	var id19 = stringIDToTypeID( "sliceType" );
	var id20 = stringIDToTypeID( "user" );
	desc6.putEnumerated( id18, id19, id20 );
	var id21 = charIDToTypeID( "At  " );
	  var desc7 = new ActionDescriptor();
	  var id22 = charIDToTypeID( "Top " );
	  var id23 = charIDToTypeID( "#Rlt" );
	  desc7.putUnitDouble( id22, id23, 92.000000 );
	  var id24 = charIDToTypeID( "Left" );
	  var id25 = charIDToTypeID( "#Rlt" );
	  desc7.putUnitDouble( id24, id25, 62.000000 );
	  var id26 = charIDToTypeID( "Btom" );
	  var id27 = charIDToTypeID( "#Rlt" );
	  desc7.putUnitDouble( id26, id27, 184.000000 );
	  var id28 = charIDToTypeID( "Rght" );
	  var id29 = charIDToTypeID( "#Rlt" );
	  desc7.putUnitDouble( id28, id29, 231.000000 );
	var id30 = charIDToTypeID( "Rctn" );
	desc6.putObject( id21, id30, desc7 );
  var id31 = stringIDToTypeID( "slice" );
  desc5.putObject( id17, id31, desc6 );
executeAction( id14, desc5, DialogModes.NO );
}

Save the file as "function_lib.js" in the Photoshop's "Scripts" directory: Adobe Photoshop CS > Presets > Scripts.

Now create a new script, and add an 'Include' referencing the 'funcion_lib.js' file, like so:

Next create a new script. Use an 'Include' to reference 'function_lib.js' file: // Includes an external .js file // @include 'function_lib.js'

Note: 'Include' code executes, don't let its comment-like appearance fool you.

Now call makeSlice() function located in the 'function_lib.js' file like so:


makeSlice();

Save 'my_script.js' in the 'Scripts' Directory (Adobe Photoshop CS > Presets > Scripts).

Run the script called 'my_script.js'.

Note: 'Include's must be commented out using double comment syntax: /* */.


/*// Includes an external .js file

// @include 'function_lib.js'*/
  • http://usuarios.cnba.uba.ar/gabinetes/informatica/Portable%20Adobe%20Photoshop%20CS3%20en%20Espa%C3%B1ol/Presets/Scripts/