10 Replies Latest reply: Dec 10, 2012 5:57 AM by domnic.rj23 RSS

    Batch processing layers

    RaydioRay1

      Hi,

       

      I am making some cinemagraphs and have many layers (frame captures) that I need to edit. I'd like to make the same lighting and color adjustment on each layer. Unless I am missing something, this can be a laboriuous task, involving repeatedly making the same adjustments to each layer in turn. Is there an easier way?

       

      Thanks in advance for any help that can be offered.

       

      I am using:

       

      Photoshop Elements 11

      Windows 7 Home Premium

        • 1. Re: Batch processing layers
          domnic.rj23 Community Member

          Sorry but I couldn't understand what you meant by "many layers (frame captures) ", If you have different layers in same document, you can always use actions or script to adjust your each layer with the settings you want.

          If you have different image documents on which you want to apply the same settings, you can use Process multiple files( from File> Process multiple Files). Please note that from Process multiple file, you can only choose to apply auto corrections

          For rest other cases, you are left with no choice but to write a script. You can find people ready to help you for writing the script on the forum if you could explain them your needs

          • 2. Re: Batch processing layers
            RaydioRay1 Community Member

            Thank you, Domnic, and I aplogize for not making myself clearer.

             

            I do indeed need to make the same adjustements to multiple layers in the same document. From what you say, it looks like I need to learn how to write scripts. Does anyone know of a good resource that could give me guidance in learning how to write scripts for Photoshop Elements (11)?

             

            Thanks again for the help.

            • 3. Re: Batch processing layers
              domnic.rj23 Community Member

              Even though you can run scripts from PSE, it doesn't provide support for writing scripts. You would have to find documentation from Photoshop about writing script. In addition to it, you would need ExtendScript Tool Kit for debugging your script, which comes with Photoshop. So, I would advice you that instead of learning scripting you should look for some existing script that serves your purpose with minor modifications.

              • 4. Re: Batch processing layers
                domnic.rj23 Community Member

                I am posting a simplest script for adjusting all the layers in the active document with brightness 30 and contrast 40. Please copy the text betwen the line "script start" and "script end" to notepad and rename it as "script.jsx" (please make sure that the file is saved with extension .jsx and not .txt). To run the script, open your image document with multiple layers and then go to File>open and choose the file script.jsx and click open

                ---------------------script start-----------------------------

                #target pseeditor

                //Author: Domnic.rj23

                var docRef=app.activeDocument;

                var layerlength=docRef.artLayers.length;

                var layerRef=null;

                for(i=0;i<layerlength;i++){

                    layerRef=docRef.artLayers[i];

                    layerRef.adjustBrightnessContrast(30,40); //  brightness = [-100..100] and contrast =[-100..100].

                    //layerRef.adjustColorBalance(); // [shadows][, midtones][, highlights][, preserveLuminosity]   For shadows, midtones, and highlights, the array must include three values in the range [-100..100],for CMYK/RGB

                    //layerRef.adjustLevels(inputRangeStart,inputRangeEnd,inputRangeGamma,outputRangeStart,ou tputRangeEnd);

                    }

                ---------------------script end-----------------------------

                • 5. Re: Batch processing layers
                  RaydioRay1 Community Member

                  Dominic!

                   

                  Apologies for the late reply but I have been away for a few days and just picked up your message.

                   

                  Thank you very, very much for posting this script, and giving such clear instructions on its use. I did as you said with one of my files and the script ran beautifully.

                   

                  I am going to try using this script as a template and modify it for specific files, as you suggested above.

                   

                  Thank you so very much, Dominic!

                   

                  Ray

                  • 6. Re: Batch processing layers
                    domnic.rj23 Community Member

                    Glad to be of help.

                    Happy Editing

                     

                    ./Domnic

                    • 7. Re: Batch processing layers
                      RaydioRay1 Community Member

                      Hi Dominic,

                       

                      I haven't had much luck modifying your script, so would like to ask some follow up questions. Here is what I am seeing.

                       

                      1. The script "works" for me in PE11, in that it modifies the brightness and contrast in all the layers successively. However, on closer inspection, the resulting changes in brightness and contrast are not what I expected for the values of 40, 30 that you gave as the default. When I make a manual change of Brightness, Contrast of 40,30 I get a very different looking image/layer.

                       

                      2. I tried changing the values of 40,30 in this line of the code:

                       

                      layerRef.adjustBrightnessContrast(30,40); //  brightness = [-100..100] and contrast =[-100..100].

                       

                      to:

                       

                      layerRef.adjustBrightnessContrast(50,70); //  brightness = [-100..100] and contrast =[-100..100].

                       

                      Again, the results were not the same as appear when I manually make the changes on one or two layers.

                       

                      3. I notice that that the "limits" used on your code are "-100..100". I thought that perhas this was the problem, as in PE11 Brightness can be adjusted in value from -150 to +150, and Contrast can change from -50 to +100. I changed the line of code above to reflect these limits:

                       

                      layerRef.adjustBrightnessContrast(30,40); //  brightness = [-150..150] and contrast =[-50..100].

                       

                      I ran the script again, but once more the resulting adjustments were very different than the changes seen when adjusted manually.

                       

                      Have you any idea what I am doing wrong, Dominic? Maybe I have misunderstood who to modify your code?

                       

                      Thank in advance for any further help you can offer, and thanks again for your help so far.

                       

                      Ray

                      • 8. Re: Batch processing layers
                        domnic.rj23 Community Member

                        Hi Ray,

                        Sorry about not checking the results of the script before giving out to you. There indeed is a difference between the results. So I tried looking to the bottom of this thing and found that Photoshop has made changes to its code that was used for adjusting brightness and contrast in the image. In Photoshop, both the codes are available for use from a checkbox "Use Legacy".But in PSE, only the newer code is available for use The function I called actually uses the legacy adjustment and thus has the range of [-100,100] for brightness and contrast. With newer code, the range has changed to [-150,150] for brightness and [-50,100] for contrast.

                        I thus modified the code to include a recorded function from Photoshop and now it looks like this

                        ---------------------script start-----------------------------

                        #target pseeditor

                        //Author: Domnic.rj23

                        main=function(brightness,contrast){

                        var docRef=app.activeDocument;

                        var layerlength=docRef.artLayers.length;

                        var layerName=null;

                        for(i=0;i<layerlength;i++){

                            layerName=docRef.artLayers[i].name;

                            selectLayer(layerName);

                            adjustBrightnessContrast(brightness,contrast);

                            }

                        }

                        selectLayer=function(layerName){

                        var idslct = charIDToTypeID( "slct" );

                            var desc3 = new ActionDescriptor();

                            var idnull = charIDToTypeID( "null" );

                                var ref1 = new ActionReference();

                                var idLyr = charIDToTypeID( "Lyr " );

                                ref1.putName( idLyr, layerName);

                            desc3.putReference( idnull, ref1 );

                            var idMkVs = charIDToTypeID( "MkVs" );

                            desc3.putBoolean( idMkVs, false );

                        executeAction( idslct, desc3, DialogModes.NO );   

                        }

                           

                        adjustBrightnessContrast=function (brightness,contrast){

                        var idBrgC = charIDToTypeID( "BrgC" );

                            var desc2 = new ActionDescriptor();

                            var idBrgh = charIDToTypeID( "Brgh" );

                            desc2.putInteger( idBrgh, brightness );

                            var idCntr = charIDToTypeID( "Cntr" );

                            desc2.putInteger( idCntr, contrast );

                            var iduseLegacy = stringIDToTypeID( "useLegacy" );

                            desc2.putBoolean( iduseLegacy, false );

                        executeAction( idBrgC, desc2, DialogModes.NO );

                        }

                         

                        main(40,30); // main (brightness,contrast)

                         

                        ---------------------script end-----------------------------

                         

                        The functions used in the scripts were recorded from Photoshop and should be replaced later by more reliable inbuild functions. But I believe it would solve the issue you were facing and would work well fine with large documents ( you may see a little flicker when the script runs. It may get significant if the large documents are used)

                         

                         

                        P.S. The text after "//" till the end of line are comments and they have no role in code. I thus have reduced comments so that the code remains more cleaned up

                        • 9. Re: Batch processing layers
                          RaydioRay1 Community Member

                          Hi Dominick,

                           

                          You are very kind to have provided so much help. I really appreciate it.

                           

                          The new script works perfectly, and I am now using it quite easily to make batch adjustments of Brightness/Contrast to layers. It is a great time saver!

                           

                          I have one last (I hope) question. Can I modify this script to make other batch adjustments to layers? In the project I am working on, I also routinely adjust Hue/Saturation, and Sharpness.

                           

                          Again, Dominick. Thanks for your help and your time.

                           

                          Ray

                          • 10. Re: Batch processing layers
                            domnic.rj23 Community Member

                            Hi Ray,

                            Glad to here the script is working fine for you.

                            Here is the script for adjusting your brightness/contrast along with hue/saturation/lightness. For sharpness, I need to know what kind of sharpness do you use. I mean out of Adjust Sharpness, unsharpmask or Auto sharpen.

                            If you want to learn how to make your own recorded scripts, do let me know

                             

                            ---------------------script start-----------------------------

                             

                            #target pseeditor

                            //Author: Domnic.rj23

                            main=function(){

                            var docRef=app.activeDocument;

                            var layerlength=docRef.artLayers.length;

                            var layerName=null;

                            for(i=0;i<layerlength;i++){

                                layerName=docRef.artLayers[i].name;

                                selectLayer(layerName);

                                adjustBrightnessContrast(0,0);//input brightness and contrast values. ex: 30,40

                                      adjustHueSaturationLightness(44,0,0); //input Hue, Saturation, lightness values. ex: 40,0,0

                                }

                            }

                            selectLayer=function(layerName){

                            var idslct = charIDToTypeID( "slct" );

                                var desc3 = new ActionDescriptor();

                                var idnull = charIDToTypeID( "null" );

                                    var ref1 = new ActionReference();

                                    var idLyr = charIDToTypeID( "Lyr " );

                                    ref1.putName( idLyr, layerName);

                                desc3.putReference( idnull, ref1 );

                                var idMkVs = charIDToTypeID( "MkVs" );

                                desc3.putBoolean( idMkVs, false );

                            executeAction( idslct, desc3, DialogModes.NO );  

                            }

                              

                            adjustBrightnessContrast=function (brightness,contrast){

                            var idBrgC = charIDToTypeID( "BrgC" );

                                var desc2 = new ActionDescriptor();

                                var idBrgh = charIDToTypeID( "Brgh" );

                                desc2.putInteger( idBrgh, brightness );

                                var idCntr = charIDToTypeID( "Cntr" );

                                desc2.putInteger( idCntr, contrast );

                                var iduseLegacy = stringIDToTypeID( "useLegacy" );

                                desc2.putBoolean( iduseLegacy, false );

                            executeAction( idBrgC, desc2, DialogModes.NO );

                            }

                             

                             

                            adjustHueSaturationLightness=function(Hue,Saturation,Lightness){

                            var idHStr = charIDToTypeID( "HStr" );

                                var desc2 = new ActionDescriptor();

                                var idpresetKind = stringIDToTypeID( "presetKind" );

                                var idpresetKindType = stringIDToTypeID( "presetKindType" );

                                var idpresetKindCustom = stringIDToTypeID( "presetKindCustom" );

                                desc2.putEnumerated( idpresetKind, idpresetKindType, idpresetKindCustom );

                                var idClrz = charIDToTypeID( "Clrz" );

                                desc2.putBoolean( idClrz, false );

                                var idAdjs = charIDToTypeID( "Adjs" );

                                    var list1 = new ActionList();

                                        var desc3 = new ActionDescriptor();

                                        var idH = charIDToTypeID( "H   " );

                                        desc3.putInteger( idH, Hue );

                                        var idStrt = charIDToTypeID( "Strt" );

                                        desc3.putInteger( idStrt,Saturation );

                                        var idLght = charIDToTypeID( "Lght" );

                                        desc3.putInteger( idLght, Lightness );

                                    var idHsttwo = charIDToTypeID( "Hst2" );

                                    list1.putObject( idHsttwo, desc3 );

                                desc2.putList( idAdjs, list1 );

                            executeAction( idHStr, desc2, DialogModes.NO );

                            }

                            main();

                            ---------------------script end-----------------------------