Combine two channels to generate a new channel

Community Beginner ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

Hi everyone, I don't have a solid grasp with JavaScript, but I wanna ask if is possible reproduce the applyimage function using a script as in the attached picture.

 

apply image.png

I'm looking the way to generate a new channel (green for example) from a splited channels (cyan and yellow).

is it possible?

My goal is to add two spot channels (red ,green) to cmyk image, and generate six color separations for screen printing.  I appreciate your help.

TOPICS
Actions and scripting , Windows

Views

55

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

There is no "standard" object model code. So use scripting listener to record action manager code, you may need to swap out the document name with a variable for the current doc if using this on different files.

 

Here is an example from a different script using different values, with the raw SL code passed through the Clean SL script:

 

https://community.adobe.com/t5/photoshop/place-embedded-one-sequence-to-another-sequence/m-p/1199816...

 
 
Edit: Another example of a scripted Apply Image is in the link below:
 
 

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

@marlon248285867nip  – Here is the raw SL recorded JS code:

 

var idapplyImageEvent = stringIDToTypeID( "applyImageEvent" );
    var desc361 = new ActionDescriptor();
    var idwith = stringIDToTypeID( "with" );
        var desc362 = new ActionDescriptor();
        var idto = stringIDToTypeID( "to" );
            var ref48 = new ActionReference();
            var idchannel = stringIDToTypeID( "channel" );
            var idordinal = stringIDToTypeID( "ordinal" );
            var idtargetEnum = stringIDToTypeID( "targetEnum" );
            ref48.putEnumerated( idchannel, idordinal, idtargetEnum );
            var idlayer = stringIDToTypeID( "layer" );
            var idbackground = stringIDToTypeID( "background" );
            ref48.putProperty( idlayer, idbackground );
            var iddocument = stringIDToTypeID( "document" );
            ref48.putName( iddocument, "18.jpg_Yellow" );
        desc362.putReference( idto, ref48 );
        var idinvert = stringIDToTypeID( "invert" );
        desc362.putBoolean( idinvert, true );
        var idcalculation = stringIDToTypeID( "calculation" );
        var idcalculationType = stringIDToTypeID( "calculationType" );
        var idlinearDodge = stringIDToTypeID( "linearDodge" );
        desc362.putEnumerated( idcalculation, idcalculationType, idlinearDodge );
        var idpreserveTransparency = stringIDToTypeID( "preserveTransparency" );
        desc362.putBoolean( idpreserveTransparency, true );
        var iduseMask = stringIDToTypeID( "useMask" );
            var ref49 = new ActionReference();
            var idchannel = stringIDToTypeID( "channel" );
            var idordinal = stringIDToTypeID( "ordinal" );
            var idtargetEnum = stringIDToTypeID( "targetEnum" );
            ref49.putEnumerated( idchannel, idordinal, idtargetEnum );
            var idlayer = stringIDToTypeID( "layer" );
            var idbackground = stringIDToTypeID( "background" );
            ref49.putProperty( idlayer, idbackground );
            var iddocument = stringIDToTypeID( "document" );
            ref49.putName( iddocument, "18.jpg_Yellow" );
        desc362.putReference( iduseMask, ref49 );
        var idinvertMask = stringIDToTypeID( "invertMask" );
        desc362.putBoolean( idinvertMask, true );
    var idcalculation = stringIDToTypeID( "calculation" );
    desc361.putObject( idwith, idcalculation, desc362 );
executeAction( idapplyImageEvent, desc361, DialogModes.NO );

 

Here it is in a function using the Clean SL script:

 

applyImageEvent(true, true, true);

function applyImageEvent(invert, preserveTransparency, invertMask) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};

	var descriptor = new ActionDescriptor();
	var descriptor2 = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();

	reference.putEnumerated( s2t( "channel" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	reference.putProperty( s2t( "layer" ), s2t( "background" ));
	reference.putName( s2t( "document" ), "18.jpg_Yellow" );
	descriptor2.putReference( s2t( "to" ), reference );
	descriptor2.putBoolean( s2t( "invert" ), invert );
	descriptor2.putEnumerated( s2t( "calculation" ), s2t( "calculationType" ), s2t( "linearDodge" ));
	descriptor2.putBoolean( s2t( "preserveTransparency" ), preserveTransparency );
	reference2.putEnumerated( s2t( "channel" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	reference2.putProperty( s2t( "layer" ), s2t( "background" ));
	reference2.putName( s2t( "document" ), "18.jpg_Yellow" );
	descriptor2.putReference( s2t( "useMask" ), reference2 );
	descriptor2.putBoolean( s2t( "invertMask" ), invertMask );
	descriptor.putObject( s2t( "with" ), s2t( "calculation" ), descriptor2 );
	executeAction( s2t( "applyImageEvent" ), descriptor, DialogModes.NO );
}

 

P.S. You might be able to do this via an action, I haven't tried so it may not be that easy.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jun 18, 2022 Jun 18, 2022

Copy link to clipboard

Copied

LATEST

@marlon248285867nip - are you still with us?

Likes

Translate

Translate

Report

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