create a adjustment layer using javascript and change value for separate color in separate channel.
- December 2, 2023
- 1 reply
- 691 views
// Create a new group named "A1"
var group = app.activeDocument.layerSets.add();
group.name = "A1";
// Set the document color mode to CMYK
app.activeDocument.mode = DocumentMode.CMYK;
createChannelMixerAdjustmentLayer();
// Function to create a Channel Mixer adjustment layer
function createChannelMixerAdjustmentLayer() {
// Create a new adjustment layer
var desc18 = new ActionDescriptor();
var desc19 = new ActionDescriptor();
var desc20 = new ActionDescriptor();
var ref8 = new ActionReference();
ref8.putClass(charIDToTypeID("AdjL"));
desc18.putReference(charIDToTypeID("null"), ref8);
desc20.putEnumerated(stringIDToTypeID("presetKind"), stringIDToTypeID("presetKindType"), stringIDToTypeID("presetKindDefault"));
// CMYK values
var idCyn = charIDToTypeID("Cyn ");
var desc674 = new ActionDescriptor();
desc674.putUnitDouble(idCyn, charIDToTypeID("#Prc"), 80.000000); // Set to 80%
var idChMx = charIDToTypeID("ChMx");
desc20.putObject(idCyn, idChMx, desc674);
var idMgnt = charIDToTypeID("Mgnt");
var desc675 = new ActionDescriptor();
desc675.putUnitDouble(idMgnt, charIDToTypeID("#Prc"), 60.000000); // Set to 60%
desc20.putObject(idMgnt, idChMx, desc675);
var idYlw = charIDToTypeID("Ylw ");
var desc676 = new ActionDescriptor();
desc676.putUnitDouble(idYlw, charIDToTypeID("#Prc"), 70.000000); // Set to 70%
desc20.putObject(idYlw, idChMx, desc676);
var idBlck = charIDToTypeID("Blck");
var desc677 = new ActionDescriptor();
desc677.putUnitDouble(idBlck, charIDToTypeID("#Prc"), 50.000000); // Set to 50%
desc20.putObject(idBlck, idChMx, desc677);
desc19.putObject(charIDToTypeID("Type"), charIDToTypeID("ChnM"), desc20);
desc18.putObject(charIDToTypeID("Usng"), charIDToTypeID("AdjL"), desc19);
executeAction(charIDToTypeID("Mk "), desc18, DialogModes.NO);
}
this is my code, but in this code only change same channel with same color, but i want change in
cyan channel, color value cyan=100, magenta=10, yellow=25, black=2
magenta channel, color value cyan=45, magenta=100, yellow=2, black=1
yellow channel, color value cyan=3, magenta=10, yellow=85, black=-2
black channel, color value cyan=-5, magenta=6, yellow=0, black=100
if any have solution please help me to solve my problem and if you have better solution please help me.
thank you.
