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

PS JavaScript how to paste into an alpha channel

Community Beginner ,
Feb 01, 2021 Feb 01, 2021

Hello,

 

I am trying to paste my current clipboard contents into a specific alpha channel.

say named "Alpha 6"

The document is likely to have your normal RGB + a number of alpha channels so I need to paste the contents into a specific one.

Doing it by hand works perfectly, no idea how to achieve it via script.

I already have quite a complex java script written that does a lot of things, this is just a extention of it I am trying to do and I just cant figure this bit out. So I do need to use Java for this.

 

Thanks for any help

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

Community Expert , Feb 01, 2021 Feb 01, 2021

For the clipboard to alpha, you can use this function:

 

 

function clipboardToAlpha(alphaName) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putName( s2t( "channel" ), alphaName );
	descriptor.putReference( c2t( "null" ), reference );
	executeAction( s2t( "select" ), descriptor, D
...
Translate
Adobe
Community Beginner ,
Feb 01, 2021 Feb 01, 2021

Or if there is a way to copy a LayerSet that is not necesarily on top in the document, into a alpha channel without the use of clipboard, that would be even more optimal. Thank you

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
Community Expert ,
Feb 01, 2021 Feb 01, 2021

Can you share a screenshot of your layers panel with the targeted layer group/set expanded and visible?

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
Community Expert ,
Feb 01, 2021 Feb 01, 2021

For the clipboard to alpha, you can use this function:

 

 

function clipboardToAlpha(alphaName) {
	var c2t = function (s) {
		return app.charIDToTypeID(s);
	};
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putName( s2t( "channel" ), alphaName );
	descriptor.putReference( c2t( "null" ), reference );
	executeAction( s2t( "select" ), descriptor, DialogModes.NO );
	descriptor2.putEnumerated( c2t( "AntA" ), s2t( "antiAliasType" ), s2t( "antiAliasNone" ));
	descriptor2.putClass( s2t( "as" ), s2t( "pixel" ));
	executeAction( s2t( "paste" ), descriptor2, DialogModes.NO );
}

 

 

Then call the function with the required alpha channel name as a parameter in double quotes:

 

 

clipboardToAlpha("Alpha 6"); // Alpha channel name

 

 

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
Community Beginner ,
Feb 02, 2021 Feb 02, 2021
LATEST

This worked perfectly, thank you!

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