Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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 );
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now