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

I'm not able to make a selection with script to some of specific colors

New Here ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

Hello,

I'm working on some script stuff which selects random colors by input, but there some problem with photoshop to select some colors. Just giving RGB Values through script & it's not making a selection.

Works with most of random colors, but not all. please please gimme some solution.

Here are RGB values which photoshop not selecting.

1. R:4, G:99, B:138

2. R:109, G:225, B:147

Here is the script:

var chercheCouleur = new SolidColor();

chercheCouleur.rgb.red=109;

chercheCouleur.rgb.green=225;

chercheCouleur.rgb.blue=147;

selectColorRange(chercheCouleur);

function selectColorRange(scObj)

{

    var desc = new ActionDescriptor();

    desc.putInteger( charIDToTypeID( "Fzns" ), 0 );

    var cDesc = new ActionDescriptor();

    cDesc.putDouble( charIDToTypeID( "Rd  " ), scObj.rgb.red);

    cDesc.putDouble( charIDToTypeID( "Grn " ), scObj.rgb.green);

    cDesc.putDouble( charIDToTypeID( "Bl  " ), scObj.rgb.blue );

    desc.putObject( charIDToTypeID( "Mnm " ), charIDToTypeID( "RGBC" ), cDesc );

    desc.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "RGBC" ), cDesc );

    executeAction( charIDToTypeID( "ClrR" ), desc, DialogModes.NO );

}

Thanks in advance.

TOPICS
Actions and scripting

Views

662

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 , Mar 28, 2018 Mar 28, 2018

In general, it seems that ColorRange processes all your colors in Lab mode, regardless of what mode it was given input colors.

He still converts them to Lab. And it does it on the same algorithm as Eyedropper.

This algorithm (the conversion of RGB to Lab) is different from what happens when executing such code.

var c0 = new SolidColor();

c0.model = ColorModel.LAB;

c0.rgb.red=109;

c0.rgb.green=225;

c0.rgb.blue=147;

var c1 = new SolidColor();

c1.model = ColorModel.RGB;

c1.rgb.red=109;

c1.rgb.green=225;

c1

...

Votes

Translate

Translate
Adobe
People's Champ ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

This is a bug of Photoshop СС
Read this topic sampled colors in color range is not recorded by 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
New Here ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

Thanks for reply,

I'm not talking about Photoshop СС. I'm using Photoshop CS6 13.0 x64. And it is working on most of the colors. Please go through again & check if there can be any solution for it.

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
People's Champ ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

Excuse me, but now there is no time. It's also like a bug. I'll try to figure it out later.

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 ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

In general, it seems that ColorRange processes all your colors in Lab mode, regardless of what mode it was given input colors.

He still converts them to Lab. And it does it on the same algorithm as Eyedropper.

This algorithm (the conversion of RGB to Lab) is different from what happens when executing such code.

var c0 = new SolidColor();

c0.model = ColorModel.LAB;

c0.rgb.red=109;

c0.rgb.green=225;

c0.rgb.blue=147;

var c1 = new SolidColor();

c1.model = ColorModel.RGB;

c1.rgb.red=109;

c1.rgb.green=225;

c1.rgb.blue=147;

alert(c0.lab.l.toFixed(4) + " " + c0.lab.a.toFixed(4) + " " + c0.lab.b.toFixed(4)+ "\n" +

      c1.lab.l.toFixed(4) + " " + c1.lab.a.toFixed(4) + " " + c1.lab.b.toFixed(4))

In addition, it depends on the file's profile and bit depth.

In Lab mode 16 bit, ColorRange with Fzns = 0 does not work at all adequately

For your case, you can upgrade the code like this. At least on your two colors works in RGB8 or RGB16 mode with different profiles.

var chercheCouleur = new SolidColor();

chercheCouleur.model = ColorModel.LAB;

chercheCouleur.rgb.red=109;

chercheCouleur.rgb.green=225;

chercheCouleur.rgb.blue=147;

//chercheCouleur.rgb.red=4;

//chercheCouleur.rgb.green=99;

//chercheCouleur.rgb.blue=138;

selectColorRange(chercheCouleur);

function selectColorRange(scObj)

{

    var desc = new ActionDescriptor();

    desc.putInteger( charIDToTypeID( "Fzns" ), 0 );

    var cDesc = new ActionDescriptor();

    cDesc.putDouble( charIDToTypeID( "Lmnc" ), scObj.lab.l );

    cDesc.putDouble( charIDToTypeID( "A   " ), scObj.lab.a );

    cDesc.putDouble( charIDToTypeID( "B   " ), scObj.lab.b );

    desc.putObject( charIDToTypeID( "Mnm " ), charIDToTypeID( "LbCl" ), cDesc );

    var cDesc = new ActionDescriptor();

    cDesc.putDouble( charIDToTypeID( "Rd  " ), scObj.rgb.red);

    cDesc.putDouble( charIDToTypeID( "Grn " ), scObj.rgb.green);

    cDesc.putDouble( charIDToTypeID( "Bl  " ), scObj.rgb.blue );

    desc.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "RGBC" ), cDesc );

    desc.putInteger( stringIDToTypeID( "colorModel" ), 0 );

    executeAction( charIDToTypeID( "ClrR" ), desc, 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
New Here ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

Thanks for the Valuable answer.

this worked better than my code, but it is still not selecting some range of colors

try this one :

red=60

green=105

blue=210

Thanks.

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 ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

LATEST

parveenkaloi 

try this one :

red=60

green=105

blue=210

Works fine. CS6 13.0.1.1 x64 win7
RGB8 (srgb, adobergb, working srgb)

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