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

How to change Image color like Channel mixer

New Here ,
May 13, 2009 May 13, 2009

Hello everybody

I have this problem can anyone help me:

I want to change Channel mixer color,

for example, change original Image color to B&W.

My code:

docRef.channels[0].color.rgb.red = 30;

docRef.channels[0].color.rgb.green = 59;

docRef.channels[0].color.rgb.blue = 11;

docRef.channels[1].color.rgb.red = 30;

docRef.channels[1].color.rgb.green = 59;

docRef.channels[1].color.rgb.blue = 11;

docRef.channels[2].color.rgb.red = 30;

docRef.channels[2].color.rgb.green = 59;

docRef.channels[2].color.rgb.blue = 11;

But not working in scripting, seems a mistake.

How should I correct this code? Thank you for your help.

TOPICS
Actions and scripting
2.3K
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

Guru , May 14, 2009 May 14, 2009

Your code only converts the layer to B&W because the 3 arrays have the same value. Had you used doc.layers[0].mixChannels([[60,30,10,0],[30,10,60,0],[10,60,30,0]],false); the layer would still have some color.

doc.layers[0].mixChannels([[30,59,11,0]],true); would be a clearer way to do what your code does. Note the monochrome argument is set to true.

Translate
Adobe
Valorous Hero ,
May 13, 2009 May 13, 2009

This is what I use...

BlackWhite(27,36,37);

function function BlackWhite(Red,Green,Blue) {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };

    var desc2 = new ActionDescriptor();
    desc2.putEnumerated( sTID('presetKind'), sTID('presetKindType'), sTID('presetKindCustom') );
    desc2.putBoolean( cTID('Mnch'), true );
        var desc3 = new ActionDescriptor();
        desc3.putUnitDouble( cTID('Rd  '), cTID('#Prc'), Red );
        desc3.putUnitDouble( cTID('Grn '), cTID('#Prc'), Green );
        desc3.putUnitDouble( cTID('Bl  '), cTID('#Prc'), Blue );
    desc2.putObject( cTID('Gry '), cTID('ChMx'), desc3 );
    executeAction( cTID('ChnM'), desc2, DialogModes.NO );
};

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
New Here ,
May 14, 2009 May 14, 2009

Thanks Paul Riggott.

You can solve the B&W color, I think 'docRef.backgroundLayer.desaturate()'  is a simpler method.

But I had 9 parameters, each channel has 3 parameters, each parameter's value maybe different, How can I do ?

Thank you again for your information on my question.

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
Guru ,
May 14, 2009 May 14, 2009

desaturate may be simple but it doesn't work like channel mixer. The function Paul posted does.

I am not sure what you are trying to do but a channel can not have 3 values unless it is a spot color channel. The component channels do not have a color property.

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
New Here ,
May 14, 2009 May 14, 2009

Thanks Michael L Hale.

I think you are right, you have inspired me correct understanding of the photoshop working principle.

I found the new method: Layer.mixChannel(array of array of num, false);

finally, thank Michael & Paul ,Thank you very much for you big 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
Guide ,
May 14, 2009 May 14, 2009

Yes channel mixing is a method of art layer adjustment. It requires a an array of array (each with target channel 3 values plus a constant)

I don't know how to do this in JS yet but you are now on the right method.

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
New Here ,
May 14, 2009 May 14, 2009

Hi , Muppet Mark.

you can try this code in your js

var doc=app.activeDocument;


doc.layers[0].mixChannels([[30,59,11,0],[30,59,11,0],[30,59,11,0]],false);

                                       

this is change color to B&W.

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
Guru ,
May 14, 2009 May 14, 2009

Your code only converts the layer to B&W because the 3 arrays have the same value. Had you used doc.layers[0].mixChannels([[60,30,10,0],[30,10,60,0],[10,60,30,0]],false); the layer would still have some color.

doc.layers[0].mixChannels([[30,59,11,0]],true); would be a clearer way to do what your code does. Note the monochrome argument is set to true.

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
New Here ,
May 14, 2009 May 14, 2009
LATEST

Hi Michael,

I try changed 12 parameters in array of num in my js,

doc.layers[0].mixChannels([[30,59,11,0],[30,59,11,0],[30,59,11,0]],false);

doc.layers[0].mixChannels([[30,59,11,0]],true); ------  this way is better than ↑

doc.layers[0].mixChannels([[60,30,10,0],[30,10,60,0],[10,60,30,0]],false);

doc.layers[0].mixChannels([[39,77,19,0],[35,69,17,0],[27,53,13,0]],false);

They would show new color as I wantted,

I forgot ' When monochrome = true, the maximum number of channel value specifications is 1. '

Thank you for your recommendation.

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