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

Script create curves adjustment layer with specific point

Participant ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

I want to have a script that creates the curves layer with specific point but in the channels too.

 

I found this script here, 

 

It works but i don't know how to then draw points on the red green and blue channels rather than just the composite?

Many Thanks

 

Matt

{
var c_ADJ_LAYER = charIDToTypeID( "AdjL" );
var c_ADJUSTMENT = charIDToTypeID( "Adjs" );
var c_CHANNEL = charIDToTypeID( "Chnl" );
var c_COMPOSITE = charIDToTypeID( "Cmps" );
var c_CURVE = charIDToTypeID( "Crv " );
var c_CURVE_A = charIDToTypeID( "CrvA" );
var c_CURVES = charIDToTypeID( "Crvs" );
var c_HORIZONTAL = charIDToTypeID( "Hrzn" );
var c_MAKE = charIDToTypeID( "Mk  " );
var c_NULL = charIDToTypeID( "null" );
var c_POINT = charIDToTypeID( "Pnt " );
var c_TYPE = charIDToTypeID( "Type" );
var c_USING = charIDToTypeID( "Usng" );
var c_VERTICAL = charIDToTypeID( "Vrtc" );

							
		var d_CURVES_LAYER = new ActionDescriptor();
		// Contains all the information necessary to perform the "MAKE" action
			var r_CLASS = new ActionReference();
			r_CLASS.putClass( c_ADJ_LAYER );
		d_CURVES_LAYER.putReference( c_NULL, r_CLASS );
		// Class of make action is of an ajdustment layer
			var d_TYPE_CURVES = new ActionDescriptor();
			// Contains all the information about all the curves
				var d_CHANNEL_CURVES = new ActionDescriptor();
					var l_CHANNEL_CURVES = new ActionList();
					// Contains a list of channel curves
						var d_CHANNEL_CURVE = new ActionDescriptor();
						// Information for 1 channel curve
							var r_CHANNEL = new ActionReference();
							r_CHANNEL.putEnumerated( c_CHANNEL, c_CHANNEL, c_COMPOSITE );
							// This curve is for the composite channel - VARIES
						d_CHANNEL_CURVE.putReference( c_CHANNEL, r_CHANNEL );
						// Contains the point list
							var l_POINTS = new ActionList();
							// List of points for this channel - LENGTH VARIES
								var d_POINT = new ActionDescriptor();
								// One point on the curve, has INPUT and OUTPUT value
								d_POINT.putDouble( c_HORIZONTAL, 0.000000 );
								d_POINT.putDouble( c_VERTICAL, 0.000000 );
							l_POINTS.putObject( c_POINT, d_POINT );
								//var d_POINT2 = new ActionDescriptor();
								d_POINT.putDouble( c_HORIZONTAL, 100.000000 );
								d_POINT.putDouble( c_VERTICAL, 80.000000 );
							l_POINTS.putObject( c_POINT, d_POINT );
								//var d_POINT2 = new ActionDescriptor();
								d_POINT.putDouble( c_HORIZONTAL, 200.000000 );
								d_POINT.putDouble( c_VERTICAL, 150.000000 );
							l_POINTS.putObject( c_POINT, d_POINT );
								//var d_POINT3 = new ActionDescriptor();
								d_POINT.putDouble( c_HORIZONTAL, 255.000000 );
								d_POINT.putDouble( c_VERTICAL, 255.000000 );
							l_POINTS.putObject( c_POINT, d_POINT );
							// Made the list of points
						d_CHANNEL_CURVE.putList( c_CURVE, l_POINTS );
						// Now have a list of points for a specific channel
					l_CHANNEL_CURVES.putObject( c_CURVE_A, d_CHANNEL_CURVE );
					// Add to the list of channel curves
				d_CHANNEL_CURVES.putList( c_ADJUSTMENT, l_CHANNEL_CURVES );
				// All the channel curves are inside here
			d_TYPE_CURVES.putObject( c_TYPE, c_CURVES, d_CHANNEL_CURVES );
			// .....
		d_CURVES_LAYER.putObject( c_USING, c_ADJ_LAYER, d_TYPE_CURVES );
		// package the curves and definition of the adjustment layer type
	executeAction( c_MAKE, d_CURVES_LAYER, DialogModes.NO );
}

 

 

 

TOPICS
Actions and scripting

Views

1.5K

Translate

Translate

Report

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 , May 06, 2021 May 06, 2021

Does this help? 

if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theLayer = rgbCurvesLayer ([[[0,0], [128,150], [255,255]], [[0,0], [128,110], [255,255]], [[0,0], [255,255]]]);
};
////// make rgb curves layer //////
function rgbCurvesLayer (theArray) {
    // =======================================================
    var idMk = charIDToTypeID( "Mk  " );
    var idpresetKind = stringIDToTypeID( "presetKind" );
    var idpresetKindType = stringIDToTypeID( "presetKindType"
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

Does this help? 

if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var theLayer = rgbCurvesLayer ([[[0,0], [128,150], [255,255]], [[0,0], [128,110], [255,255]], [[0,0], [255,255]]]);
};
////// make rgb curves layer //////
function rgbCurvesLayer (theArray) {
    // =======================================================
    var idMk = charIDToTypeID( "Mk  " );
    var idpresetKind = stringIDToTypeID( "presetKind" );
    var idpresetKindType = stringIDToTypeID( "presetKindType" );
    var idpresetKindDefault = stringIDToTypeID( "presetKindDefault" );
    var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );
    var idadjustmentLayer = stringIDToTypeID( "adjustmentLayer" );
    var idordinal = stringIDToTypeID( "ordinal" );
    var idtargetEnum = stringIDToTypeID( "targetEnum" );
    var idadjustment = stringIDToTypeID( "adjustment" );
    var idcurvesAdjustment = stringIDToTypeID( "curvesAdjustment" );
    var idcurves = stringIDToTypeID( "curves" );
    var idcurve = stringIDToTypeID( "curve" );
    var idchannel = stringIDToTypeID( "channel" );
    var idAdjL = charIDToTypeID( "AdjL" );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idTrgt = charIDToTypeID( "Trgt" );
    var idChnl = charIDToTypeID( "Chnl" );
    var idnull = charIDToTypeID( "null" );
    var idCrvs = charIDToTypeID( "Crvs" );
    var idCrvA = charIDToTypeID( "CrvA" );
    var idCrv = charIDToTypeID( "Crv " );
    var idAdjs = charIDToTypeID( "Adjs" );
        var desc5 = new ActionDescriptor();
            var ref2 = new ActionReference();
            ref2.putClass( idAdjL );
        desc5.putReference( idnull, ref2 );
        var idUsng = charIDToTypeID( "Usng" );
            var desc6 = new ActionDescriptor();
            var idType = charIDToTypeID( "Type" );
                var desc7 = new ActionDescriptor();
                desc7.putEnumerated( idpresetKind, idpresetKindType, idpresetKindDefault );
            desc6.putObject( idType, idCrvs, desc7 );
        desc5.putObject( idUsng, idAdjL, desc6 );
    executeAction( idMk, desc5, DialogModes.NO );
    // =======================================================
    var idset = stringIDToTypeID( "set" );
        var desc50 = new ActionDescriptor();
        var idnull = stringIDToTypeID( "null" );
            var ref5 = new ActionReference();
            ref5.putEnumerated( idadjustmentLayer, idordinal, idtargetEnum );
        desc50.putReference( idnull, ref5 );
        var idto = stringIDToTypeID( "to" );
            var desc51 = new ActionDescriptor();
                var list5 = new ActionList();
                    var desc52red = new ActionDescriptor();
                        var ref6 = new ActionReference();
                        var idblue = stringIDToTypeID( "red" );
                        ref6.putEnumerated( idchannel, idchannel, idblue );
                    desc52red.putReference( idchannel, ref6 );
                        var list6 = new ActionList();
                        var thisArray = theArray[0];
                        for (var m = 0; m < thisArray.length; m++) {
                            addCurvePoint (list6, thisArray[m])
                            };
                    desc52red.putList( idcurve, list6 );
                    var desc52green = new ActionDescriptor();
                        var ref6 = new ActionReference();
                        var thisArray = theArray[1];
                        var idblue = stringIDToTypeID( "green" );
                        ref6.putEnumerated( idchannel, idchannel, idblue );
                    desc52green.putReference( idchannel, ref6 );
                        var list6 = new ActionList();
                        for (var m = 0; m < thisArray.length; m++) {
                            addCurvePoint (list6, thisArray[m])
                            };
                    desc52green.putList( idcurve, list6 );
                    var desc52blue = new ActionDescriptor();
                        var ref6 = new ActionReference();
                        var thisArray = theArray[2];
                        var idblue = stringIDToTypeID( "blue" );
                        ref6.putEnumerated( idchannel, idchannel, idblue );
                    desc52blue.putReference( idchannel, ref6 );
                        var list6 = new ActionList();
                        for (var m = 0; m < thisArray.length; m++) {
                            addCurvePoint (list6, thisArray[m])
                            };
                    desc52blue.putList( idcurve, list6 );
                list5.putObject( idcurvesAdjustment, desc52red );
                list5.putObject( idcurvesAdjustment, desc52green );
                list5.putObject( idcurvesAdjustment, desc52blue );
            desc51.putList( idadjustment, list5 );
        desc50.putObject( idto, idcurves, desc51 );
    executeAction( idset, desc50, DialogModes.NO );
    ////////////////////////////////////
    return app.activeDocument.activeLayer;
    ////// add curve point //////
    function addCurvePoint (theList, valuePair) {
    var desc11 = new ActionDescriptor();
    desc11.putDouble( charIDToTypeID( "Hrzn" ), valuePair[0] );
    desc11.putDouble( charIDToTypeID( "Vrtc" ), valuePair[1] );
    theList.putObject( charIDToTypeID( "Pnt " ), desc11 );
    };
    };

Votes

Translate

Translate

Report

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 ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

Yes it does!!!!

Thank you, I've been digging around for the last hour and couldn't find anything!

Votes

Translate

Translate

Report

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 ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

LATEST

You can use ScriptingListener.plugin to record the code and then wrap it into a function that takes arguments in a clearer form. 

Votes

Translate

Translate

Report

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