Copy link to clipboard
Copied
How i can select alpha channel with specific name, using javascript? I work with CMYK images and i want to select alpha channel which is often caled (trap, Trap selection, selection for trap, etc.), keyword is TRAP but other parts of alpha channel name depends of users...
Thanks in advance!
The reason I couldn't understand what you want is that the thread you started was originally about manipulating selections in the panels, so when later, after few days you said 'to make selection of alpha channel' I was sure you refer to the core of very first question, not to the selection of channel on document canvas.
aD = activeDocument
if (alphs = [].slice.call(aD.channels)
.splice(aD.componentChannels.length)) {
trapChannel = false; while(alphs.length) {
splt.visible = /trap/i.test(nme
...
Copy link to clipboard
Copied
with(activeDocument) channels.length > 4
&& /trap/i.test(nme = channels[4].name) &&
activeChannels = [channels.getByName(nme)]
Copy link to clipboard
Copied
This works perfectly, but i forgot to mention that my files sometimes contains one or more spot colors, how to improve this part? Thanks
Copy link to clipboard
Copied
chnnls = (aD = activeDocument).channels
if (alphs = [].slice.call(chnnls).splice(4)) {
brk = false; while(!brk && alphs.length) {
if (/trap/i.test(nme = (splt = alphs.shift()).name))
brk = aD.activeChannels = [chnnls.getByName(nme)]
}
}
Copy link to clipboard
Copied
Perfect! Thanks a lot!
Copy link to clipboard
Copied
Could you please change code to show other channels, basically my needs are to display all channels (CMYK and spot colours) and just to make selection of alpha channel with keyword "trap"? Thanks in advance
Copy link to clipboard
Copied
Your image doesn't fit the description. On image I see component channels are displayed and selected, while spot channel is not displayed and not selected. Explain it... Regarding your text you can't have component channels and spot channel selected at same time, only dispayed.
Copy link to clipboard
Copied
Ok, sometimes my pictures are just CMYK and sometimes they contain spot channels. Is it possible to make a universal solution (or two solututions one for CMYK one for multichannel) that will select all channels and make a selection of the mentioned alpha channel?
Thank you for your dedication
Copy link to clipboard
Copied
There's an inconsistency in your request. You post now an image in multichannel mode with displayed and selected remains of CMYK channels and the spot channel. 'trap' alpha channel is undisplayed and unselected.
In your current description you say to select all channels and 'mentioned alpha channel'. The mentioned alpha channel I understand is that you mentioned in previous post where you said 'to make selection of alpha channel with keyword "trap"'.
You again post channels tree that can't be compared to your text. You want to select alpha channel 'trap' along with other channels and spots and then attach an image that shows only alpha channel 'trap' is unselected 😕
Do you think I can understand what you really want?
Ps. usually screenshots are posted to illustrate expected result, but yours make confusion.
Copy link to clipboard
Copied
Dear, images exactly ilustrate final result, please look up closly, on the second image you can find selection of alpha channel (selection on border, between glass of milk and bg) .The idea is that in both cases needs are to display and mark cmyk(cmyk +spot) channels with selection of alpha channel (trap)?
I apologize for the misunderstanding
Copy link to clipboard
Copied
The reason I couldn't understand what you want is that the thread you started was originally about manipulating selections in the panels, so when later, after few days you said 'to make selection of alpha channel' I was sure you refer to the core of very first question, not to the selection of channel on document canvas.
aD = activeDocument
if (alphs = [].slice.call(aD.channels)
.splice(aD.componentChannels.length)) {
trapChannel = false; while(alphs.length) {
splt.visible = /trap/i.test(nme = (splt = alphs.shift()).name) && !trapChannel
? !(trapChannel = true, sTT = stringIDToTypeID, (ref1 = new ActionReference())
.putProperty(chnnl = sTT('channel'), sTT('selection')), (dsc = new ActionDescriptor())
.putReference(sTT('null'), ref1), (ref2 = new ActionReference()).putName(chnnl, nme),
dsc.putReference(sTT('to'), ref2), executeAction(sTT('set'), dsc)) : true
}
}
Copy link to clipboard
Copied
Yeah, that got me too... It would have helped if Adobe used the term "target" when dealing with "selecting channels or layers" in their respective panels, rather than a "select"... Too many selections!
Copy link to clipboard
Copied
Thanks @Kukurykus, sorry for misunderstanding, I will mark last code as correct answer
Copy link to clipboard
Copied
Dear @Kukurykus could you improve this script, how to alert user if this kind of alpha channel does not exist? Thanks in advance