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

Set Gray Point in Curves

Participant ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

I want to remove single color in Set Gray Point in curves ! In this script only add curves layer

// =======================================================
var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
var desc8 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putClass( charIDToTypeID( "AdjL" ));
desc6.putReference( charIDToTypeID( "null" ), ref2 );
desc8.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindDefault" ));
desc7.putObject( charIDToTypeID( "Type" ), charIDToTypeID( "Crvs" ), desc8 );
desc6.putObject( charIDToTypeID( "Usng" ), charIDToTypeID( "AdjL" ), desc7 );
executeAction( charIDToTypeID( "Mk " ), desc6, DialogModes.NO );

// =======================================================
var desc10 = new ActionDescriptor();
var desc11 = new ActionDescriptor();
var desc12 = new ActionDescriptor();
var desc13 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
var list1 = new ActionList();
var list2 = new ActionList();
var ref3 = new ActionReference();
var ref4 = new ActionReference();
ref3.putEnumerated( charIDToTypeID( "AdjL" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
desc9.putReference( charIDToTypeID( "null" ), ref3 );
desc10.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindCustom" ));
ref4.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Cyn " ));
desc11.putReference( charIDToTypeID( "Chnl" ), ref4 );
desc12.putDouble( charIDToTypeID( "Hrzn" ), 0.000000 );
desc12.putDouble( charIDToTypeID( "Vrtc" ), 0.000000 );
list2.putObject( charIDToTypeID( "Pnt " ), desc12 );
desc13.putDouble( charIDToTypeID( "Hrzn" ), 229.000000 );
desc13.putDouble( charIDToTypeID( "Vrtc" ), 229.000000 );
list2.putObject( charIDToTypeID( "Pnt " ), desc13 );
desc11.putList( charIDToTypeID( "Crv " ), list2 );
list1.putObject( charIDToTypeID( "CrvA" ), desc11 );
desc10.putList( charIDToTypeID( "Adjs" ), list1 );
desc9.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Crvs" ), desc10 );
executeAction( charIDToTypeID( "setd" ), desc9, DialogModes.NO );

TOPICS
Actions and scripting

Views

1.9K

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

People's Champ , Jun 17, 2021 Jun 17, 2021
Here is the code The get_average_color function can be found here Get color from selected area
 
var c = new SolidColor()
get_average_color(c);

var r = c.rgb.red;
var g = c.rgb.green;
var b = c.rgb.blue;

add_curves(undefined, [[0,0],[r,128],[255,255]], [[0,0],[g,128],[255,255]], [[0,0],[b,128],[255,255]]);

function add_curves(c, r, g, b, k, use_grp, name, mode)
    {
    try {
        var d = new ActionDescriptor();
        var list = new ActionList();

        function set_chnl(name, m)
    
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

I want to remove single color in Set Gray Point in curves ! 

Could you explain what you mean by that?

Posting screenshots might save you some typing. 

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Step :- 1step1.JPG

 

Step :- 2

 

step2.JPG

 

I am using Gray Tool in Curve , To Remove any single color, So I want to automatic in scripts

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Automatic what? 

Where is the gray point supposed to be set? A fixed pixel position, a Color Sampler, …? 

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

I want to set automatically gray point whicever color ?

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Please try to actually explain what you are trying to achieve. 

 

Are all the images just one solid color area each? What good would applying Curves (Layers) to those be? 

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

First Image Check It, I want apply Gray point of Eyedropper tool by Curves. To Adjustment the Single Color.

Step1:- Open Image

Step2:- Avarage Color

Step3:- Open Curves

Stpe4:- Aplly Gray Point of Eyedroper tool by Curves

 

These four step I want to automstically in scripts

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
People's Champ ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Try Image->Adjustments->Match Color - tick Neutralize.

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Yes @r-bin  That is perfect But I want Curve Layer Using Gray Tools, Is that possible to scripts !

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
People's Champ ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Yes, but, I don't have time for this.
There is no ready-made code and the code will be long.
 
Maybe  Kukurykus wrote a short one in his own unrivaled style. : )
 

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Please write the code

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Just Write 2Step Code:- 

1- Add Curves

2- Gray Point in Eyedroper tools by Curves

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
People's Champ ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Add.

 

Moreover, it is not clear whether you want to turn the average color into (128,128,128) or just remove saturation from it. Curves can be curves, linear or charcoal. The question is ambiguous, because the final goals in real images are not clear.

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Yes That is final goals, Please write the code :-

Add the Curve Layer in below scripts---

Can you set a Gray Point By Curves:- 

var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
var desc8 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putClass( charIDToTypeID( "AdjL" ));
desc6.putReference( charIDToTypeID( "null" ), ref2 );
desc8.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindDefault" ));
desc7.putObject( charIDToTypeID( "Type" ), charIDToTypeID( "Crvs" ), desc8 );
desc6.putObject( charIDToTypeID( "Usng" ), charIDToTypeID( "AdjL" ), desc7 );
executeAction( charIDToTypeID( "Mk " ), desc6, DialogModes.NO );

// =======================================================
var desc10 = new ActionDescriptor();
var desc11 = new ActionDescriptor();
var desc12 = new ActionDescriptor();
var desc13 = new ActionDescriptor();
var desc9 = new ActionDescriptor();
var list1 = new ActionList();
var list2 = new ActionList();
var ref3 = new ActionReference();
var ref4 = new ActionReference();
ref3.putEnumerated( charIDToTypeID( "AdjL" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
desc9.putReference( charIDToTypeID( "null" ), ref3 );
desc10.putEnumerated( stringIDToTypeID( "presetKind" ), stringIDToTypeID( "presetKindType" ), stringIDToTypeID( "presetKindCustom" ));
ref4.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "Cyn " ));
desc11.putReference( charIDToTypeID( "Chnl" ), ref4 );
desc12.putDouble( charIDToTypeID( "Hrzn" ), 0.000000 );
desc12.putDouble( charIDToTypeID( "Vrtc" ), 0.000000 );
list2.putObject( charIDToTypeID( "Pnt " ), desc12 );
desc13.putDouble( charIDToTypeID( "Hrzn" ), 229.000000 );
desc13.putDouble( charIDToTypeID( "Vrtc" ), 229.000000 );
list2.putObject( charIDToTypeID( "Pnt " ), desc13 );
desc11.putList( charIDToTypeID( "Crv " ), list2 );
list1.putObject( charIDToTypeID( "CrvA" ), desc11 );
desc10.putList( charIDToTypeID( "Adjs" ), list1 );
desc9.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Crvs" ), desc10 );
executeAction( charIDToTypeID( "setd" ), desc9, DialogModes.NO );

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
People's Champ ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Here is the code The get_average_color function can be found here Get color from selected area
 
var c = new SolidColor()
get_average_color(c);

var r = c.rgb.red;
var g = c.rgb.green;
var b = c.rgb.blue;

add_curves(undefined, [[0,0],[r,128],[255,255]], [[0,0],[g,128],[255,255]], [[0,0],[b,128],[255,255]]);

function add_curves(c, r, g, b, k, use_grp, name, mode)
    {
    try {
        var d = new ActionDescriptor();
        var list = new ActionList();

        function set_chnl(name, m)
            {
            if (m == undefined || m == null) return;

            var d = new ActionDescriptor();
            var r = new ActionReference();
            r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID(name));
            d.putReference(stringIDToTypeID("channel"), r);

            var lst = new ActionList();

            for (var i = 0; i < m.length; i++)
                {
                if (m[i] == undefined) continue;    

                var d1 = new ActionDescriptor();
                d1.putDouble(stringIDToTypeID("horizontal"), m[i][0]);
                d1.putDouble(stringIDToTypeID("vertical"),   m[i][1]);
                lst.putObject(stringIDToTypeID("point"), d1);
                }

            d.putList(stringIDToTypeID("curve"), lst);

            list.putObject(stringIDToTypeID("curvesAdjustment"), d);
            }

        if (app.activeDocument.mode == DocumentMode.RGB)
            {               
            set_chnl("composite", c);
            set_chnl("red",       r);
            set_chnl("green",     g);
            set_chnl("blue",      b);
            }
        else if (app.activeDocument.mode == DocumentMode.LAB)
            {               
            set_chnl("lightness", r);
            set_chnl("a",         g);
            set_chnl("b",         b);
            }
        else if (app.activeDocument.mode == DocumentMode.CMYK)
            {               
            set_chnl("composite", c);
            set_chnl("cyan",      r);
            set_chnl("magenta",   g);
            set_chnl("yellow",    b);
            set_chnl("black",     k);
            }
        else { return false; }

        d.putList(stringIDToTypeID("adjustment"), list);
         
        return add_adjustment_layer("curves", d, name, use_grp, mode);
        } 
    catch (e) { return false; }
    }

////////////////////////////////////////////////////////////////////////////////////////////
function add_adjustment_layer(type, data, name, use_grp, mode_str, op)
    {
    try { 
        if (typeof(type) == "string") type = (type.length==4)?charIDToTypeID(type):stringIDToTypeID(type);

        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putClass(stringIDToTypeID("adjustmentLayer"));
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();

        if (name)    d1.putString(stringIDToTypeID("name"), name);
        if (use_grp) d1.putBoolean(stringIDToTypeID("group"), true);

        if (mode_str != undefined)
            {
            var mode = mode_str;
            if (typeof(mode_str) == "string") mode = (mode_str.length==4)?charIDToTypeID(mode_str):stringIDToTypeID(mode_str);

            d1.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), mode);
            }

        if (op != undefined) d1.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), op);

        if (data == null || data == undefined) data = new ActionDescriptor();

        d1.putObject(stringIDToTypeID("type"), type, data);
        d.putObject(stringIDToTypeID("using"), stringIDToTypeID("adjustmentLayer"), d1);

        executeAction(stringIDToTypeID("make"), d, DialogModes.NO);

        return true;
        } 
    catch (e) { return false; }
    }

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 ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Thanks @r-bin  I will try

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
LEGEND ,
Jun 20, 2021 Jun 20, 2021

Copy link to clipboard

Copied

LATEST

Why this answer was marked as correct if it's not a solution to the problem?

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
LEGEND ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

You look at it wrong way. It's like 2 different people listen to different music, and the one that likes Jazz, cannot understand the other prefers Hip Hop. Or going deeper true street hip hop and luxury's or else Smooth Jazz against Classic Jazz. Similary how can you want to be white when I am happy beeing black 😄 It is funny you do not do something the way I do, really?

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