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

Set color replacement tool

Participant ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

I would like to change the data of the color replacement tool brush

Schermata 2021-07-16 alle 17.14.35.png
with a script
I know it can be done with a .tpl file
But I've seen somewhere in the past that it can be done with a script
can someone help me

TOPICS
Actions and scripting

Views

523

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

Valorous Hero , Jul 19, 2021 Jul 19, 2021

I do not set parameters for the tools, because it doesn't work in CS6. Only setting parameters for the brush descriptor works.

 

Here is the complete code for this tool. I think you yourself will figure out where and what.

 

var op = new ActionDescriptor();

op.putEnumerated(charIDToTypeID("CRTm"), stringIDToTypeID("blendMode"), stringIDToTypeID("color")); // hue, saturation, color, luminosity
op.putInteger(stringIDToTypeID("tolerance"), 30);
op.putInteger(charIDToTypeID("CRSm"), 0);    // samp
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

Did you actually state what you want to change the settings to? 

 

I am not sure how well a Script could handle that anyway but it seems curious to me that someone serious enough about working in Photoshop to investigate Scripting approaches would even use the Color Replacement Tool – to me it seems useless for serious work. 

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
Valorous Hero ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

quote

...

even use the Color Replacement Tool – to me it seems useless for serious work. 


By @c.pfaffenbichler

 

And you know, for example, that I actively use this tool. But through the script, I only select it and set the 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
Participant ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

Mr. r-bin
I also use this tool a lot and every time I have to change all the settings

so if you can do it with scripts it would help me
more than anything else, it's a lesson in programming a script

thank you

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 ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied


and every time I have to change all the settings

What do you want to change the Tool’s settings to? 

How many different combinations of settings do you want to invoke via Script? 

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
Valorous Hero ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

I do not set parameters for the tools, because it doesn't work in CS6. Only setting parameters for the brush descriptor works.

 

Here is the complete code for this tool. I think you yourself will figure out where and what.

 

var op = new ActionDescriptor();

op.putEnumerated(charIDToTypeID("CRTm"), stringIDToTypeID("blendMode"), stringIDToTypeID("color")); // hue, saturation, color, luminosity
op.putInteger(stringIDToTypeID("tolerance"), 30);
op.putInteger(charIDToTypeID("CRSm"), 0);    // sampling options: 0,1,2
op.putInteger(charIDToTypeID("CRCg"), 1);    // limits: 0,1,2 
op.putBoolean(charIDToTypeID("CRAl"), true); // anti-alias


/**************  these parameters can be omitted, all or part 

op.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("revert")); // it is not known why 

var CRRc = new ActionDescriptor();
CRRc.putDouble(stringIDToTypeID("red"),   0);
CRRc.putDouble(stringIDToTypeID("green"), 0);
CRRc.putDouble(stringIDToTypeID("blue"),  0);
op.putObject(charIDToTypeID("CRRc"), stringIDToTypeID("RGBColor"), CRRc); 

var CRTc = new ActionDescriptor();
CRTc.putDouble(stringIDToTypeID("red"),   0);
CRTc.putDouble(stringIDToTypeID("green"), 0);
CRTc.putDouble(stringIDToTypeID("blue"),  0);
op.putObject(charIDToTypeID("CRTc"), stringIDToTypeID("RGBColor"), CRTc); 

op.putBoolean(stringIDToTypeID("usePaintDynamics"), true);
op.putBoolean(stringIDToTypeID("useBrushPose"), false);
op.putDouble(stringIDToTypeID("smoothingValue"), 0);
op.putBoolean(stringIDToTypeID("smoothingRadiusMode"), false);
op.putBoolean(stringIDToTypeID("smoothingCatchup"), true);
op.putBoolean(stringIDToTypeID("smoothingCatchupAtEnd"), false);
op.putBoolean(stringIDToTypeID("smoothingZoomCompensation"), true);
op.putBoolean(stringIDToTypeID("pressureSmoothing"), false);
op.putBoolean(stringIDToTypeID("usePressureOverridesSize"), false);
op.putBoolean(stringIDToTypeID("usePressureOverridesOpacity"), false);
op.putBoolean(stringIDToTypeID("useLegacy"), false);

// brush settings

var brush = new ActionDescriptor();
brush.putUnitDouble(stringIDToTypeID("diameter"), stringIDToTypeID("pixelsUnit"), 13);
brush.putUnitDouble(stringIDToTypeID("hardness"), stringIDToTypeID("percentUnit"), 100);
brush.putUnitDouble(stringIDToTypeID("angle"), stringIDToTypeID("angleUnit"), 0);
brush.putUnitDouble(stringIDToTypeID("roundness"), stringIDToTypeID("percentUnit"), 100);
brush.putUnitDouble(stringIDToTypeID("spacing"), stringIDToTypeID("percentUnit"), 25);
brush.putBoolean(charIDToTypeID("Intr"), true);
brush.putBoolean(stringIDToTypeID("flipX"), false);
brush.putBoolean(stringIDToTypeID("flipY"), false);
op.putObject(stringIDToTypeID("brush"), stringIDToTypeID("computedBrush"), brush);

op.putBoolean(stringIDToTypeID("useTipDynamics"), true);
op.putBoolean(stringIDToTypeID("flipX"), false);
op.putBoolean(stringIDToTypeID("flipY"), false);
op.putBoolean(stringIDToTypeID("brushProjection"), false);
op.putUnitDouble(stringIDToTypeID("minimumDiameter"), stringIDToTypeID("percentUnit"), 0);
op.putUnitDouble(stringIDToTypeID("minimumRoundness"), stringIDToTypeID("percentUnit"), 25);
op.putUnitDouble(stringIDToTypeID("tiltScale"), stringIDToTypeID("percentUnit"), 200);

var prVr = new ActionDescriptor();
prVr.putInteger(charIDToTypeID("bVTy"), 0);
prVr.putInteger(charIDToTypeID("fStp"), 25);
prVr.putUnitDouble(stringIDToTypeID("jitter"), stringIDToTypeID("percentUnit"), 0);
prVr.putUnitDouble(stringIDToTypeID("minimum"), stringIDToTypeID("percentUnit"), 0);
op.putObject(charIDToTypeID("prVr"), charIDToTypeID("brVr"), prVr);

var szVr = new ActionDescriptor();
szVr.putInteger(charIDToTypeID("bVTy"), 2);
szVr.putInteger(charIDToTypeID("fStp"), 25);
szVr.putUnitDouble(stringIDToTypeID("jitter"), stringIDToTypeID("percentUnit"), 0);
szVr.putUnitDouble(stringIDToTypeID("minimum"), stringIDToTypeID("percentUnit"), 0);
op.putObject(charIDToTypeID("szVr"), charIDToTypeID("brVr"), szVr);

var angleDynamics = new ActionDescriptor();
angleDynamics.putInteger(charIDToTypeID("bVTy"), 0);
angleDynamics.putInteger(charIDToTypeID("fStp"), 25);
angleDynamics.putUnitDouble(stringIDToTypeID("jitter"), stringIDToTypeID("percentUnit"), 0);
angleDynamics.putUnitDouble(stringIDToTypeID("minimum"), stringIDToTypeID("percentUnit"), 0);
op.putObject(stringIDToTypeID("angleDynamics"), charIDToTypeID("brVr"), angleDynamics);

var roundnessDynamics = new ActionDescriptor();
roundnessDynamics.putInteger(charIDToTypeID("bVTy"), 0);
roundnessDynamics.putInteger(charIDToTypeID("fStp"), 25);
roundnessDynamics.putUnitDouble(stringIDToTypeID("jitter"), stringIDToTypeID("percentUnit"), 0);
roundnessDynamics.putUnitDouble(stringIDToTypeID("minimum"), stringIDToTypeID("percentUnit"), 0);
op.putObject(stringIDToTypeID("roundnessDynamics"), charIDToTypeID("brVr"), roundnessDynamics);

****************/

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

d.putObject(stringIDToTypeID("to"), stringIDToTypeID("null"), op);
executeAction(stringIDToTypeID("set"), d, 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
Participant ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

LATEST

r-bin
just what I was looking for
thank you.

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 ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied


And you know, for example, that I actively use this tool. But through the script, I only select it and set the color.

I was not aware of that; in which context do you usually use it?

Which advantages does it offer to you compared to a Layer (or Solid Color Layer or Adjustment Layer) with the appropriate Blend Mode? 

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 ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

I work with images with a green background
unfortunately a green dominant remains on the outskirts
to remove it I use this tool

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