Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I want to script multiple tweaks to create multiple jpgs with the different tweaks applied.

Participant ,
Jul 09, 2025 Jul 09, 2025

Windows 11 laptop, always using the latest version of Photoshop.

Almost all of my Photoshop work involves birds.  For the workflow, I create high-quality (12) jpgs and open them in the Windows “Photos” App before deciding on the final version.  I'm very obsessive about the final product.  As an example, a few weeks ago, while in Photoshop, I selected the subject, decreased brightness by 45 and exported a high-quality (12) jpg.  I then reverted the change, decreased by 46 and exported another jpg.  I repeated this in increments of 1, all the way up to 70.  I named the files intuitively and went with the -63 version. 

I’ve done similar things with additional saturation applied to the subject only, as well as additional contrast applied to the inverse of the subject and to the sky. 

There has to be a way to save time by automating this that will not involve spending as much time tweaking the automation script as I would have spent by saving down the multiple files.  I name things intuitively, such as DSCN2352-13.jpg, so maybe some programming logic in the script can do this as well.  If not, I can just figure out by the order of the files what changes were applied.  Is there any stock JavaScript code that can handle this for the active selection?  I’d love to just be able to change a few things such as the output directory, and the attribute to be changed, (plus the direction where to start and end) such as brightness, contrast, and saturation.

I know how to record an action, however, how the heck would Photoshop figure out to keep with the naming convention and to follow the different increments, as well as to know when to stop?

TOPICS
Windows
517
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Community Expert , Jul 10, 2025 Jul 10, 2025

Yeah, you would only need to set it up once. Then you would switch out your image each time you'd want to run it.

 

While you're setting it up, you could make all your duplicate Brightness Adjustment layers with the keyboard shortcut and then go back to set the value of each. To set them, you could click on the brightness icon in the Layers panel while the Properties panel is open and enter the value. You could just click on the next one and enter the value until you had incremented them all.

Translate
Community Expert , Jul 11, 2025 Jul 11, 2025

Screenshot 2025-07-11 at 10.54.24.pngScreenshot 2025-07-11 at 10.54.50.png

// create brightness contrast variations as jpgs;
// 2025, use it at your own risk;
if (app.documents.length > 0) {
//////////////////////////////////////////
var thedoc = app.activeDocument;
var docName = thedoc.name;
try {
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = thedoc.path;
}
catch (e) {
var basename = thedoc.name;
var docPath = "~/Desktop"
};
var theMin = -10;
var theMax = 10;
var theCopy = thedoc.duplicate ("thecopy", false);
brightnessContrastLayer ();
for (var m =
...
Translate
Mentor , Jul 15, 2025 Jul 15, 2025

I had a similar task and saved a sketch of an old script using adjustment layers (slightly adapted it to your task):

Screenshot 2025-07-15 222515.png

s2t = stringIDToTypeID;
var apl = new AM('application'),
    doc = new AM('document'),
    lr = new AM('layer'),
    adjustments = {
        'Brightness/Contrast': { brightness: 100, contrast: 100, option: 'useLegacy' },
        'Hue/Saturation': { hue: 180, lightness: 100, saturation: 100 }
    }
if (apl.getProperty('numberOfDocuments')) {
    showDialog(adjustments);
}
function s
...
Translate
Adobe
Community Expert ,
Jul 10, 2025 Jul 10, 2025

If you'd like to automate the creation of multiple versions of an image with incremental changes to the brightness with the naming you want and control over the directory, you could use Adjustment Layers and Layer Comps in a template. Here's how:

  1. Open your image in Photoshop
  2. Add a Brightness and Contrast Adjustment layer by clicking on the black & white cookie icon (the middle one) at the bottom of the Layers panel and selecting Brightnes/Contrast...
  3. With the Adjustment layer selected, set the Brightness value
  4. Duplicate the Adjustment layer (Command + J, macOS or Control + J, Windows)
  5. Increment the Adjustment layer manually
  6. Repeat steps 4 & 5 until you have all the incremental adjustments that you want
  7. Open the Layer Comps panel (Window > Layer Comps)
  8. With the Layers panel also open, turn off the visibility (deselect the eyeballs) so that only the image and the 1st Adjustment layer are visible
  9. In the Layers Comp panel, click the + button at the bottom of the panel to add an Adjustment Layer
  10. Name the Adjustment Layer the name you want the final file to be and under Apply to Layers, make sure that Visibility is selected (the others can be selected, but this is the one you need for what you're doing)
  11. Toggle off the visibility for the Adjustment Layer and toggle on the visibility for the next Adjustment Layer
  12. Repeat Steps 10 and 11 until you have created Layer Comps for all of the Adjustment Layers
  13. Go to File > Export > Layer Comps to Files...
  14. Set the folder for your Destinatio, remove the File Name Prefix (and make sure it's deselected), and set the File Type to JPEG with the Quality set to 12
  15.  Click Run

 

After you set this file up, you can use it as a template for the next image. You would just need to replace the image.

 

You can also let Photoshop do the naming for you by naming the Layer Comps with incremental numbers and using a File Name Prefix. Photosho will add the File Name Prefix in addition to its own a incremental number (_0000, _0001, _0002...) plus the name of your Layer Comp. You'd get an extra incremental number, but using the File Name Prefix might be easier than renaming your Layer Comps for each image.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2025 Jul 10, 2025

@Myra Ferguson I very much appreciate your detailed response, however, having to repeat steps 4 and 5, and 10 and 11 so many times, (I often save 25+ jpgs) in addition to all of the other steps, will be more time-consuming than my current workflow, as well as a lot more of a pain.

I'm looking for a way to greatly speed up my workflow, not simply an alternate workflow, especially a more cumbersome one.

Edit - I just noticed:

"After you set this file up, you can use it as a template for the next image."  So, maybe, I can just do a lot of the groundwork first, and save multiple templates based on different tweaks.  

I was hoping instead for some javascript code, but maybe this could work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2025 Jul 10, 2025

Yeah, you would only need to set it up once. Then you would switch out your image each time you'd want to run it.

 

While you're setting it up, you could make all your duplicate Brightness Adjustment layers with the keyboard shortcut and then go back to set the value of each. To set them, you could click on the brightness icon in the Layers panel while the Properties panel is open and enter the value. You could just click on the next one and enter the value until you had incremented them all.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2025 Jul 10, 2025

K - I'll try this sometime next week.  If it works (hopefully 😊) I'll mark your initial reply as the correct answer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2025 Jul 10, 2025

Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible? 

You don’t mention Adjustment Layers, so just to make sure: You are no tapplying the Adjustment destructively? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2025 Jul 10, 2025

@c.pfaffenbichler I'm not adding any screenshots.  I am indeed doing this destructively in one layer, but after each save, I just ctrl z out of the last change and make the next incremental one, and so on.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2025 Jul 10, 2025
quote

@c.pfaffenbichler I'm not adding any screenshots. 


By @Mark37430984r9lw


Just an observation... As one of the regular contributors of scripts to those coming to this forum who want a script but can't do it themselves, there are very good reasons why @c.pfaffenbichler requested this from you.

 

I would also request screenshots to ensure that I understood the request so as not to waste time coding something that wasn't required.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2025 Jul 10, 2025
quote

For the workflow, I create high-quality (12) jpgs and open them in the Windows “Photos” App before deciding on the final version.  


By @Mark37430984r9lw


As an alternative, a script could make the changes and store them as temporary snapshots in the History panel, rather than writing out JPEGs for review in other software. You could then review in Photoshop and save or export the winning snapshot.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2025 Jul 10, 2025
quote

I’d love to just be able to change a few things such as the output directory, and the attribute to be changed, (plus the direction where to start and end) such as brightness, contrast, and saturation.

 

Yes, all of this is possible.

 

You need to be very specific on the exact step-by-step workflow, in order for someone to help code this. Which exact commands in what exact order. When are certain steps applied to the isolated subject, isolated background or globally.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2025 Jul 10, 2025

I'm replying to a few of your posts.  Unlikely I'd ever want to globally change anything.  Usually with a subject, but it may also be with the sky or inverse of the subject.  Goals vary.  It could be to increase or decrease brightness, or to increase saturation.  

Regarding:

"As an alternative, a script could make the changes and store them as temporary snapshots in the History panel, rather than writing out JPEGs for review in other software. You could then review in Photoshop and save or export the winning snapshot."  

Yeah, my workflow would be much faster if I were comfortable staying in Photoshop, but I really like the finished jpg views with the Windows Photos app.

I was really hoping for a JavaScript solution. I actually worked with ChatGpg for hours on this and it finally came up with a solution, although it was awful.  The attached JavaScript files do what I want, as the outputted jpgs get progressively darker, BUT, they look nothing at all like the jpgs I made with the same selection and the same numbered brightness decreases.  The script sproduced files were harsh and awful.   I worked with so many bad scripts, that I don’t remember which one of these worked with subjexts only, (probably the intuitevly named one) but in any event, my point about the awful quality of the photos holds. So @Stephen Marsh, can you tweak one of these to actually produce jpgs that are identical to the ones that the brightness slider produces with the same selection?  The forum does not allow me to upload jsk files, so I renamed them to have docx extensions.

For you as well as @c.pfaffenbichler here is the screenshot you requested.  My view may be this, or it may only have the original background layer.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 10, 2025 Jul 10, 2025

The forum deleted the docx files, so here is a paste of both JavaScript files.

Batchbrightnesssexport.jsx:

// Create array of brightness values from -20 to -70 in steps of 1
var brightnessValues = [];
for (var b = -20; b >= -70; b--) {
brightnessValues.push(b);
}

// Reference the open document
var doc = app.activeDocument;

// Define save folder
var saveFolder = new Folder("D:/birding/batchtest");
if (!saveFolder.exists) {
saveFolder.create();
}

// Loop through each brightness value
for (var i = 0; i < brightnessValues.length; i++) {
var b = brightnessValues[i];

// Duplicate document to work on
var dupDoc = doc.duplicate();

// Apply Brightness/Contrast adjustment
dupDoc.activeLayer.adjustBrightnessContrast(b, 22);

// Prepare save options for high-quality JPG
var jpgOptions = new JPEGSaveOptions();
jpgOptions.quality = 12;

// Define file path — saves to D:\birding\batchtest
var saveFile = new File(saveFolder + "/" + doc.name.replace(/\.[^\.]+$/, '') + "_brightness" + b + ".jpg");

// Save the file
dupDoc.saveAs(saveFile, jpgOptions, true);

// Close the duplicate without saving
dupDoc.close(SaveOptions.DONOTSAVECHANGES);
}

batchbrightnessexportsubjext.jsx:

var brightnessValues = [];
for (var b = -20; b >= -70; b--) brightnessValues.push(b);

var doc = app.activeDocument;
var saveFolder = new Folder("D:/birding/batchtest");
if (!saveFolder.exists) saveFolder.create();

for (var i = 0; i < brightnessValues.length; i++) {
var bVal = brightnessValues[i];
var dupDoc = doc.duplicate();

dupDoc.activeLayer.adjustBrightnessContrast(bVal, 22);

var jpgOptions = new JPEGSaveOptions();
jpgOptions.quality = 12;
var saveFile = new File(saveFolder + "/" + dupDoc.name.replace(/\.[^\.]+$/, '') + "_brightness" + bVal + ".jpg");
dupDoc.saveAs(saveFile, jpgOptions, true);
dupDoc.close(SaveOptions.DONOTSAVECHANGES);
}




Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2025 Jul 11, 2025

Screenshot 2025-07-11 at 10.54.24.pngScreenshot 2025-07-11 at 10.54.50.png

// create brightness contrast variations as jpgs;
// 2025, use it at your own risk;
if (app.documents.length > 0) {
//////////////////////////////////////////
var thedoc = app.activeDocument;
var docName = thedoc.name;
try {
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var docPath = thedoc.path;
}
catch (e) {
var basename = thedoc.name;
var docPath = "~/Desktop"
};
var theMin = -10;
var theMax = 10;
var theCopy = thedoc.duplicate ("thecopy", false);
brightnessContrastLayer ();
for (var m = theMin; m <= theMax; m++) {
editBrightnessContrastLayer (m);
saveJpgCopy (theCopy, docPath, basename, false, 12, "_"+String(m), true);
};
theCopy.close(SaveOptions.DONOTSAVECHANGES);
};
////// create brightness contrast layer //////
function brightnessContrastLayer () {
var desc17 = new ActionDescriptor();
var ref5 = new ActionReference();
ref5.putClass( stringIDToTypeID( "adjustmentLayer" ) );
desc17.putReference( stringIDToTypeID( "null" ), ref5 );
var desc18 = new ActionDescriptor();
desc18.putBoolean( stringIDToTypeID( "group" ), true );
var desc19 = new ActionDescriptor();
var iduseLegacy = stringIDToTypeID( "useLegacy" );
desc19.putBoolean( iduseLegacy, false );
desc18.putObject( stringIDToTypeID( "type" ), stringIDToTypeID( "brightnessEvent" ), desc19 );
desc17.putObject( stringIDToTypeID( "using" ), stringIDToTypeID( "adjustmentLayer" ), desc18 );
executeAction( stringIDToTypeID( "make" ), desc17, DialogModes.NO );
};
////// edit brightness contrast layer //////
function editBrightnessContrastLayer (theB) {
var desc23 = new ActionDescriptor();
var ref6 = new ActionReference();
ref6.putEnumerated( stringIDToTypeID( "adjustmentLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc23.putReference( stringIDToTypeID( "null" ), ref6 );
var desc24 = new ActionDescriptor();
var idbrightness = stringIDToTypeID( "brightness" );
desc24.putInteger( idbrightness, theB );
desc24.putInteger( stringIDToTypeID( "center" ), 0 );
desc24.putBoolean( stringIDToTypeID( "useLegacy" ), false );
desc23.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "brightnessEvent" ), desc24 );
executeAction( stringIDToTypeID( "set" ), desc23, DialogModes.NO );
};
////// save jpg copy //////
function saveJpgCopy (thedoc, docPath, basename, srgb, theQuality, theSuffix, overwrite) {
/* check for existing file */
if (overwrite == false && File(docPath+'/'+basename+theSuffix+'.jpg').exists == true) {
	var theConfirm = confirm("overwrite existing file");
	if (theConfirm == false) {return false}
	};
/* make copy and save */
if (app.documents.length > 0) {
try {
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = theQuality;
jpegOptions.embedColorProfile = true;
/* duplicate */
if (thedoc.mode == DocumentMode.BITMAP) {
var theCopy = thedoc.duplicate ("thecopy", true);
var idCnvM = charIDToTypeID( "CnvM" );
var desc2 = new ActionDescriptor();
var idT = charIDToTypeID( "T   " );
var desc3 = new ActionDescriptor();
var idRt = charIDToTypeID( "Rt  " );
desc3.putInteger( idRt, 1 );
var idGrys = charIDToTypeID( "Grys" );
desc2.putObject( idT, idGrys, desc3 );
executeAction( idCnvM, desc2, DialogModes.NO );
}
else {
if (thedoc.mode == DocumentMode.LAB || thedoc.mode == DocumentMode.DUOTONE || thedoc.mode == DocumentMode.INDEXEDCOLOR || thedoc.mode == DocumentMode.MULTICHANNEL) {
var theCopy = thedoc.duplicate ("thecopy", true);
var idCnvM = charIDToTypeID( "CnvM" );
var desc114 = new ActionDescriptor();
var idT = charIDToTypeID( "T   " );
var idRGBM = charIDToTypeID( "RGBM" );
desc114.putClass( idT, idRGBM );
executeAction( idCnvM, desc114, DialogModes.ALL );
}
else {
var theCopy = thedoc.duplicate("thecopy", true)
}
};
/* convert */
if (srgb == true) {
theCopy.convertProfile ("sRGB IEC61966-2.1", Intent.RELATIVECOLORIMETRIC, true, true)
};
theCopy.saveAs((new File(docPath+'/'+basename+theSuffix+'.jpg')),jpegOptions,true);
theCopy.close(SaveOptions.DONOTSAVECHANGES)
}
catch (e) {docName+" failed"}
}
};
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 10, 2025 Jul 10, 2025
quote

Usually with a subject, but it may also be with the sky or inverse of the subject.  Goals vary.  It could be to increase or decrease brightness, or to increase saturation.


By @Mark37430984r9lw

 

 

OK, from the screenshot I can now see that you have a simple layer structure, no artboards or groups to complicate things.

 

Do you select the subject, then make Brightness and or Hue/Saturation adjustments etc. Then adjust everything else independently of the subject? Or select sky without the subject etc?

 

In order to script the steps, they need to be layed out like @Myra Ferguson did in her detailed step-by-step example.

 

A moving target is hard to hit :]

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 15, 2025 Jul 15, 2025
LATEST

I had a similar task and saved a sketch of an old script using adjustment layers (slightly adapted it to your task):

Screenshot 2025-07-15 222515.png

s2t = stringIDToTypeID;
var apl = new AM('application'),
    doc = new AM('document'),
    lr = new AM('layer'),
    adjustments = {
        'Brightness/Contrast': { brightness: 100, contrast: 100, option: 'useLegacy' },
        'Hue/Saturation': { hue: 180, lightness: 100, saturation: 100 }
    }
if (apl.getProperty('numberOfDocuments')) {
    showDialog(adjustments);
}
function showDialog(p) {
    var w = new Window('dialog{text:"Script settings",orientation:"column",alignChildren:["fill","top"]}'),
        grMode = w.add('group{orientation:"row"}'),
        dlMode = grMode.add('dropdownlist{preferredSize:[150,-1]}'),
        dlTarget = grMode.add('dropdownlist{preferredSize:[150,-1]}'),
        grFrom = w.add('group{preferredSize:[300,-1],orientation:"row",alignChildren:["left","center"]}'),
        stFrom = grFrom.add('statictext{text:"From",preferredSize:[50,-1]}'),
        slFrom = grFrom.add('slider{preferredSize:[200,-1]}'),
        stFromValue = grFrom.add('statictext{preferredSize:[35,-1],justify:"right"}'),
        grTo = w.add('group{preferredSize:[300,-1],orientation:"row",alignChildren:["left","center"]}'),
        stTo = grTo.add('statictext{text:"To",preferredSize:[50,-1]}'),
        slTo = grTo.add('slider{preferredSize:[200,-1]}'),
        stToValue = grTo.add('statictext{preferredSize:[35,-1],justify:"right"}'),
        grStep = w.add('group{preferredSize:[300,-1],orientation:"row",alignChildren:["left","center"]}'),
        stStep = grStep.add('statictext{text:"Step",preferredSize:[50,-1]}'),
        slStep = grStep.add('slider{preferredSize:[200,-1]}'),
        stStepValue = grStep.add('statictext{preferredSize:[35,-1],justify:"right"}'),
        chOptions = w.add('checkbox'),
        grBn = w.add('group{orientation:"row",alignChildren:["center","center"]}'),
        ok = grBn.add("button", undefined, "Save to folder...", { name: "ok" }),
        cancel = grBn.add("button", undefined, "Cancel", { name: "cancel" });
    slFrom.value = 0;
    slTo.value = 0;
    slStep.minvalue = 1;
    slStep.maxvalue = 20;
    slStep.value = 1;
    dlMode.onChange = function () {
        cur = p[this.selection.text];
        do { dlTarget.remove(dlTarget.items[0]) } while (dlTarget.items.length)
        for (a in cur) if (a != 'option') dlTarget.add('item', a)
        dlTarget.selection = 0;
        if (cur['option']) chOptions.text = chOptions.visible = cur['option'] else chOptions.visible = false
    }
    dlTarget.onChange = function () {
        updateSliders(p[dlMode.selection.text][this.selection.text])
    }
    w.onShow = function () {
        for (a in p) dlMode.add('item', a)
        dlMode.selection = 0
    }
    function updateSliders(cur) {
        if (cur) {
            slFrom.minvalue = slTo.minvalue = -cur;
            slFrom.maxvalue = slTo.maxvalue = cur;
        }
        stFromValue.text = parseInt(slFrom.value)
        stToValue.text = parseInt(slTo.value)
        stStepValue.text = parseInt(slStep.value)
        ok.enabled = (slFrom.value != slTo.value)
    }
    ok.onClick = function () {
        var f = ((new Folder).selectDlg());
        if (f) {
            w.close()
            var title = doc.getProperty('title').replace(/\..+$/, '');
            activeDocument.suspendHistory('Save Adjustments',
                "processFiles(f,\
                title,\
                dlMode.selection.text,\
                dlTarget.selection.text,\
                Math.min(parseInt(stFromValue.text), parseInt(stToValue.text)),\
                Math.max(parseInt(stFromValue.text), parseInt(stToValue.text)),\
                parseInt(slStep.value),\
                chOptions.value)")
        }
    }
    slFrom.addEventListener('keydown', sliderHandler)
    slTo.addEventListener('keydown', sliderHandler)
    slStep.addEventListener('keydown', sliderHandler)
    slFrom.addEventListener('changing', sliderHandler)
    slTo.addEventListener('changing', sliderHandler)
    slStep.addEventListener('changing', sliderHandler)
    function sliderHandler(evt) {
        evt.preventDefault();
        if (evt.keyIdentifier == 'Right' || evt.keyIdentifier == 'Up') {
            evt.target.value += slStep.value
        } else if (evt.keyIdentifier == 'Left' || evt.keyIdentifier == 'Down') {
            evt.target.value -= slStep.value
        }
        updateSliders()
    }
    w.show();
}
function processFiles(pth, title, mode, param, min, max, step, option) {
    switch (mode) {
        case 'Brightness/Contrast':
            doc.makeAdjustmentLayer('brightnessContrast')
            for (var i = min; i <= max; i += step) {
                for (a in adjustments[mode]) adjustments[mode][a] = a != param ? 0 : i
                lr.setBrightnessContrast(adjustments[mode]['brightness'], adjustments[mode]['contrast'], option)
                activeDocument.saveAs(File(pth + '/' + title + ' ' + param + ' ' + i), function () { var o = new JPEGSaveOptions; o.quality = 12; return o }(), true)
            }
            break;
        case 'Hue/Saturation':
            doc.makeAdjustmentLayer('hueSaturation')
            for (var i = min; i <= max; i += step) {
                for (a in adjustments[mode]) adjustments[mode][a] = a != param ? 0 : i
                lr.setHueSaturation(adjustments[mode]['hue'], adjustments[mode]['saturation'], adjustments[mode]['lightness'])
                activeDocument.saveAs(File(pth + '/' + title + ' ' + param + ' ' + i), function () { var o = new JPEGSaveOptions; o.quality = 12; return o }(), true)
            }
            break;
    }
    doc.restoreSelection();
    doc.removeAdjustmentLayer();
}
function AM(target, order) {
    var s2t = stringIDToTypeID,
        t2s = typeIDToStringID;
    target = target ? s2t(target) : null;
    this.getProperty = function (property, descMode, id, idxMode) {
        property = s2t(property);
        (r = new ActionReference).putProperty(s2t('property'), property);
        id != undefined ? (idxMode ? r.putIndex(target, id) : r.putIdentifier(target, id)) :
            r.putEnumerated(target, s2t('ordinal'), order ? s2t(order) : s2t('targetEnum'));
        return descMode ? executeActionGet(r) : getDescValue(executeActionGet(r), property);
    }
    this.hasProperty = function (property, id, idxMode) {
        property = s2t(property);
        (r = new ActionReference).putProperty(s2t('property'), property);
        id ? (idxMode ? r.putIndex(target, id) : r.putIdentifier(target, id))
            : r.putEnumerated(target, s2t('ordinal'), s2t('targetEnum'));
        try { return executeActionGet(r).hasKey(property) } catch (e) { return false }
    }
    this.descToObject = function (d) {
        var o = {}
        for (var i = 0; i < d.count; i++) {
            var k = d.getKey(i)
            o[t2s(k)] = getDescValue(d, k)
        }
        return o
    }
    this.makeAdjustmentLayer = function (type) {
        (r = new ActionReference()).putClass(s2t("adjustmentLayer"));
        (d = new ActionDescriptor()).putReference(s2t("null"), r);
        (d1 = new ActionDescriptor()).putObject(s2t("type"), s2t(type), new ActionDescriptor());
        d.putObject(s2t("using"), s2t("adjustmentLayer"), d1);
        executeAction(s2t("make"), d, DialogModes.NO);
    }
    this.setHueSaturation = function (hue, saturation, lightness) {
        (r = new ActionReference()).putEnumerated(s2t("adjustmentLayer"), s2t("ordinal"), s2t("targetEnum"));
        (d = new ActionDescriptor()).putReference(s2t("null"), r);
        (d1 = new ActionDescriptor()).putEnumerated(s2t("presetKind"), s2t("presetKindType"), s2t("presetKindCustom"));
        (d2 = new ActionDescriptor()).putEnumerated(s2t("channel"), s2t("channel"), s2t("composite"));
        d2.putInteger(s2t("hue"), hue);
        d2.putInteger(s2t("saturation"), saturation);
        d2.putInteger(s2t("lightness"), lightness);
        (l = new ActionList()).putObject(s2t("hueSatAdjustmentV2"), d2);
        d1.putList(s2t("adjustment"), l);
        d.putObject(s2t("to"), s2t("hueSaturation"), d1);
        executeAction(s2t("set"), d, DialogModes.NO);
    }
    this.setBrightnessContrast = function (brightness, contrast, useLegacy) {
        (r = new ActionReference()).putEnumerated(s2t("adjustmentLayer"), s2t("ordinal"), s2t("targetEnum"));
        (d = new ActionDescriptor()).putReference(s2t("null"), r);
        (d1 = new ActionDescriptor()).putInteger(s2t("brightness"), brightness);
        d1.putInteger(s2t("contrast"), contrast);
        d1.putBoolean(s2t("useLegacy"), useLegacy);
        d.putObject(s2t("to"), s2t("brightnessContrast"), d1);
        executeAction(s2t("set"), d, DialogModes.NO);
    }
    this.restoreSelection = function () {
        (r = new ActionReference()).putProperty(s2t("channel"), s2t("selection"));
        (d = new ActionDescriptor()).putReference(s2t("null"), r);
        (r1 = new ActionReference()).putEnumerated(s2t("channel"), s2t("ordinal"), s2t("targetEnum"));
        d.putReference(s2t("to"), r1);
        executeAction(s2t("set"), d, DialogModes.NO);
    }
    this.removeAdjustmentLayer = function () {
        (r = new ActionReference()).putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
        (d = new ActionDescriptor()).putReference(s2t("null"), r);
        executeAction(s2t("delete"), d, DialogModes.NO);
    }
    function getDescValue(d, p) {
        switch (d.getType(p)) {
            case DescValueType.OBJECTTYPE: return { type: t2s(d.getObjectType(p)), value: d.getObjectValue(p) };
            case DescValueType.LISTTYPE: return d.getList(p);
            case DescValueType.REFERENCETYPE: return d.getReference(p);
            case DescValueType.BOOLEANTYPE: return d.getBoolean(p);
            case DescValueType.STRINGTYPE: return d.getString(p);
            case DescValueType.INTEGERTYPE: return d.getInteger(p);
            case DescValueType.LARGEINTEGERTYPE: return d.getLargeInteger(p);
            case DescValueType.DOUBLETYPE: return d.getDouble(p);
            case DescValueType.ALIASTYPE: return d.getPath(p);
            case DescValueType.CLASSTYPE: return d.getClass(p);
            case DescValueType.UNITDOUBLE: return (d.getUnitDoubleValue(p));
            case DescValueType.ENUMERATEDTYPE: return { type: t2s(d.getEnumerationType(p)), value: t2s(d.getEnumerationValue(p)) };
            default: break;
        };
    }
}

 

 
 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines