paazmaya.fi

The Website of Juga Paazmaya | Stories about Web Development, Japanese Martial Arts, Hardware prototyping and travelling

Photoshop CS4 scripting - Fix darkness

On most of my photos which are taken during the dark times, such as night, will need simple adjustments.

Idea in the script is simply this, in JavaScript version of Photoshop scriptinglanguages:

var shadowAmount = 1; // [0..100]
var shadowWidth = 0; // [0.100]
var shadowRadius = 0; // [0..2500] pixels
var highlightAmount = 0; // [0..100]
var highlightWidth = 0; // [0..100]
var highlightRadius = 0; // [0..2500] pixels
var colorCorrection = 4; // [-100..100]
var midtoneContrast = 0; // [-100..100]
var blackClip = 0.01; // [0.000..50.000]
var whiteClip = 0.01; // [0.000..50.000]

var brightness = 0.2; // [-100..100]
var contrast = 0.1; // [-100..100]

function fix_darkness()
{
    var layer = artLayer;

    layer.shadowHighlight(
        shadowAmount,
        shadowWidth,
        shadowRadius,
        highlightAmount,
        highlightWidth,
        highlightRadius,
        colorCorrection,
        midtoneContrast,
        blackClip,
        whiteClip
    );

    layer.adjustBrightnessContrast(
        brightness,
        contrast
    );
}

This function will adjust the range of tones in the image’s shadows and highlights. Amounts and widths are percentage values. Radius values are in pixels.

The native dialogue in Photoshop CS2…CS4 can accomplish this, but in two steps, first for shadow/highlight, second brightness/contrast.

I would like to extend this script to be able to apply to the currently active image and/or Bridge selection, directory, etc., but as this script has been under its way for three years now, I’ve decided to post this small part which is the core functionality as per title.