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

Create New Curve layer with Algorithm options by script

Explorer ,
Feb 13, 2025 Feb 13, 2025

hi everyone,

I want to create an adjustment curve layer with "Enhance Monochromatic Contrast" algorithm option by using script. 

 

The image is described as below.

C1.PNGexpand image

Please guide me the exact command.

I appreciate your help

TOPICS
Actions and scripting
160
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 1 Correct answer

Community Expert , Feb 13, 2025 Feb 13, 2025

@powerful_Zephyr5EF9 â€“ Try this, it seems to work:

 

/*
Auto Curves Adjustment Layer.jsx
Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/create-new-curve-layer-with-algorithm-options-by-script/m-p/15150149
https://community.adobe.com/t5/photoshop-ecosystem-discussions/create-new-curve-layer-with-algorithm-options-3-by-script/m-p/15161955
*/

#target photoshop

// Create the curves adjustment layer
var desc397 = new ActionDescriptor();
var ref88 = new ActionReference(
...
Translate
Adobe
Community Expert ,
Feb 13, 2025 Feb 13, 2025

@powerful_Zephyr5EF9 â€“ Try this, it seems to work:

 

/*
Auto Curves Adjustment Layer.jsx
Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/create-new-curve-layer-with-algorithm-options-by-script/m-p/15150149
https://community.adobe.com/t5/photoshop-ecosystem-discussions/create-new-curve-layer-with-algorithm-options-3-by-script/m-p/15161955
*/

#target photoshop

// Create the curves adjustment layer
var desc397 = new ActionDescriptor();
var ref88 = new ActionReference();
ref88.putClass(stringIDToTypeID("adjustmentLayer"));
desc397.putReference(stringIDToTypeID("null"), ref88);
var desc398 = new ActionDescriptor();
var desc399 = new ActionDescriptor();
desc399.putEnumerated(stringIDToTypeID("presetKind"), stringIDToTypeID("presetKindType"), stringIDToTypeID("presetKindDefault"));
desc398.putObject(stringIDToTypeID("type"), stringIDToTypeID("curves"), desc399);
desc397.putObject(stringIDToTypeID("using"), stringIDToTypeID("adjustmentLayer"), desc398);
executeAction(stringIDToTypeID("make"), desc397, DialogModes.NO);

// Set the values of the curves adjustment layer
var desc412 = new ActionDescriptor();
var ref94 = new ActionReference();
ref94.putEnumerated(stringIDToTypeID("adjustmentLayer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
desc412.putReference(stringIDToTypeID("null"), ref94);
var desc413 = new ActionDescriptor();
desc413.putEnumerated(stringIDToTypeID("presetKind"), stringIDToTypeID("presetKindType"), stringIDToTypeID("presetKindCustom"));
var list62 = new ActionList();
var desc414 = new ActionDescriptor();
var ref95 = new ActionReference();
ref95.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("composite"));
desc414.putReference(stringIDToTypeID("channel"), ref95);

// 1) Enhance Monochromatic Contrast = "autoContrast"
// 2) Enhance Per Channel Contrast = "auto"
// 3) Find Dark & Light Colors = "autoBlackWhite"
// 4) Enhance Brightness and Contrast = "autoMachineLearning"
desc414.putBoolean(stringIDToTypeID("auto"), true); // Enter one of the four previous auto parameters here

// Snap neutral midtones
desc414.putBoolean(stringIDToTypeID("autoNeutrals"), true); // Only valid for the first 3 auto parameters

// Apply the auto curves adjustment
list62.putObject(stringIDToTypeID("curvesAdjustment"), desc414);
desc413.putList(stringIDToTypeID("adjustment"), list62);
desc412.putObject(stringIDToTypeID("to"), stringIDToTypeID("curves"), desc413);
executeAction(stringIDToTypeID("set"), desc412, DialogModes.NO);

// Set the layer blend mode
//app.activeDocument.activeLayer.blendMode = BlendMode.LUMINOSITY;

// Set the layer opacity
//app.activeDocument.activeLayer.opacity = 50;

 

EDIT: I have updated the code to include references to all four auto options and snap neutral midtones.

 

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
Explorer ,
Feb 13, 2025 Feb 13, 2025
LATEST

it works.
I can't thank you enough, I really appreciate your help.

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