skip to Main Content

)

I really hope the someone can help out. I just need to change depth from 32 to 16 bit without merging the layers. The code for changing depth is as follows:

activeDocument.bitsPerChannel = BitsPerChannelType.SIXTEEN;

..however it flattens the image (merges all layers).

I’ve tried:

BitsPerChannelType.SIXTEEN.WITOUTMERGER; BitsPerChannelType.SIXTEEN.WithoutMerger;

..but it didn’t work. I can of course call an action from the script like I do to apply exposure adjustment layer app.doAction ("Exposure", "Processing");. But it just annoys me 😉 not knowing how.

Best regards 😊

2

Answers


  1. Chosen as BEST ANSWER

    Implemented!! :D

    function exeAction (Type, subType, Value) {
    
    if (Type == 'Mode') {
        var desc27 = new ActionDescriptor();
        var idCnvM = charIDToTypeID ('CnvM');
        var idMrge = charIDToTypeID ('Mrge');
        desc27.putBoolean (idMrge, false);
    
            if (subType == 'Depth') {
                var idDpth = charIDToTypeID ('Dpth');
                desc27.putInteger (idDpth, Value);}
            else if (subType == 'Color') {}
        
        executeAction (idCnvM, desc27, DialogModes.NO);}
    }
    

    ..tested and it works like a charm. Now I just need to find the rest of the IDcodes 😉 and the function will continue to grow. I’ve found this page Photoshop Scripting & Extension Reference which will become useful. Better than the Object Mode Viewer. I’ve also found the Photoshop Javascript Ref 2020 however neither ‘Dpth’ nor ‘Mrge’ are listed under the Appendix A. ☹ Nevertheless, I’ve also discovered the ScriptingListener plug-in 😊😊😊. I was hoping to find something like this. Haven’t tested it yet, doubt that it’s gonna be a walk in the park, haha.

    Once again thank you so much, you contribution was godsent for my motivation :D


  2. To convert from 32 bit to 16 without merging use:

    var idCnvM = charIDToTypeID( "CnvM" );
    var desc27 = new ActionDescriptor();
    var idDpth = charIDToTypeID( "Dpth" );
    desc27.putInteger( idDpth, 16 );
    var idMrge = charIDToTypeID( "Mrge" );
    desc27.putBoolean( idMrge, false );
    executeAction( idCnvM, desc27, DialogModes.NO );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search