Scripting the ‘Shop

Probably the most advanced feature in Photoshop is its ability to be scripted. Using either VBScript (for PCs) or AppleTalk (for Macs) or Javascript (for both), you can run any and all commands of the Photoshop interface with the addition of programming functionality (conditionals, repetitions, and recursive). This then gives you one-click access to your favorite treatments and methods. Unlike Actions, they can be programmed to self-adjust for varying sizes, resolutions, and bit-depth, giving you consistent results each and every time.
Is it hard to do? That depends on your level of programming knowledge and experience. But once completed, you just put the script in the correct presets folder and when you next open Photoshop, you will have it under File >> Scripts. What else lets you appear to be part of the programming team!

Here is an example script. It generates a LOMO effect on photographs. The major steps is it makes an appropriate selection area, inverses it, applies filters for blurring, contrast, and darkening. Then it deselects the area, and treats the complete photo to further degradation.

/* Photoshop Lomo Effect Script                        */
/* for CS3 and above.                                  */
/* Author Dana C. Andrews                              */
/*        */
/* Created May 5, 2012                                 */
/* All Rights Reserved                                 */

/* Functions Section*/
function makeLomoSelection()
var x1 = Math.round(docWidth/10)
var y1 = Math.round(docHeight/10)
var x2 = x1*9
var y2 = y1*9
var featherAmt = Math.round((docWidth * docHeight)/100000)
if (featherAmt < 75) {
    featherAmt = 75
var selMarquee = Array(Array(x1,y1),Array(x1,y2),Array(x2,y2),Array(x2,y1)) (selMarquee,SelectionType.EXTEND,featherAmt,true)

/* End Function Section */

/* NOTICE */
var msg = "WARNING - This effect will first flatten the image (merge all existing layers). Even with this flattening, the script may throw an error (its okay, just run the script a second time. This only happens when the original image was saved with layers and not flattened before running this script) \n OK to continue?"
var title = "LOMO SCRIPT EFFECT"
var ok2run = confirm(msg,false,title)
if (ok2run == true) { 
    msg = "This effect works best with normally exposed images. Compositions that are low/high key (very dark or very bright) will have those effects magnified. For darkish images, this can be interesting but pictures with blown out highlights, this effect will be too much. However, all is not lost. These  issues can be mitigated by setting the LOMO layer blend mode to Multiply (if too bright) or Screen (if too dark). Adjusting the opacity to taste."

// Save original settings then make changes to known parameters
var startRulerUnits = preferences.rulerUnits
preferences.rulerUnits = Units.PIXELS
var startTypeUnits = preferences.typeUnits
preferences.typeUnits = TypeUnits.PIXELS
var startDisplayDialogs = app.displayDialogs
app.displayDialogs = DialogModes.NO
try {
// Global variables
var docRef = app.activeDocument
var layerRef = docRef.activeLayer
var darkAmt = 100 // Static variable for darkening. Must be between 0 - 254

// Document Information section
var docWidth = docRef.width
var docHeight = docRef.height

// Make a layer for this effect
var dupLayer = layerRef.duplicate() = "Lomo"
docRef.activeLayer = dupLayer

// Make a selection 
// Invert selection
/* *** Document is now prepared. Make layer adjustments as desired *** */
} catch (e) {
    preferences.rulerUnits = startRulerUnits
    preferences.typeUnits = startTypeUnits
    app.displayDialogs = startDisplayDialogs
/* The Lomo Effect */
try {
// Blur
dupLayer.applyGaussianBlur (25)
// Adjust contrast and brightness
dupLayer.adjustBrightnessContrast (-25, 100)
// Vignette
dupLayer.adjustLevels (0,254, 1.0, 0, darkAmt)
// Add noise
dupLayer.applyAddNoise (12, NoiseDistribution.GAUSSIAN, true)
// Turn off the selection oval
// defocus it a little more
if ((docWidth * docHeight) < 5000000) {
    var dsRadius = 5
    var dsThreshold = 30
    } else {
        dsRadius = 10
        dsThreshold = 15
dupLayer.applyDustAndScratches (dsRadius, dsThreshold)
// Cool the image 
var filterColor = new SolidColor() = 00 =00 = 254
dupLayer.photoFilter(filterColor, 45, true)
// Done with Effect
} catch (e) {

// Restore original settings
preferences.rulerUnits = startRulerUnits
preferences.typeUnits = startTypeUnits
app.displayDialogs = startDisplayDialogs

// Release variable pointers

startRulerUnits = null
startTypeUnits = null
startDisplayDialogs = null
docRef = null
layerRef = null
docWidth = null
docHeight = null
x1 = null
x2 = null
y1 = null
y2 = null
featherAmt = null
darkAmt = null
selMarquee = null
dupLayer = null
filterColor = null
dsRadius = null
dsThreshold = null
} // this is where false goes if the user selects NO on the alert box about flattening image
msg = null
title = null
ok2run = null


Here are some examples of the effect applied to different image formats

Color portrait

B&W (sepia actually) portrait

Tall format but same script

Love to take pictures and love the pictures you take!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: