5 Replies Latest reply on Apr 13, 2011 7:00 AM by matteotaroni

    Auto level, split channels and save seperately.

    Barry Shortt

      Hello,

       

      I have a large amount of images that I have to process and would like to automate it if possible. This is the workflow:

       

      Open image

      Adjust - autolevels

      Split channels into red, green and blue

      Save the channels seperately with "red", "green" or "blue" added to the filenames

      Close all windows.

       

      Using the record actions feature I've been able to automate the autolevels part but I can't figure out how to automate the channel splitting and saving part. Any help would be greatly appreciated.

       

      Barry

        • 1. Re: Auto level, split channels and save seperately.
          Muppet Mark-QAl63s Level 4

          Channel splitting is in the channels palette fly out menu. It can be recorded. I don't use actions but you should be able to sort the file naming and saving via script if you can't with an action. The open documents are auto named with suffix's .red .green & .blue but I don't think this is retained when you come to the save step?

           

          This would split the channels of the active document…

           

          #target photoshop
          
          splitChannels();
          
          function splitChannels() {
               function cTID(s) { return app.charIDToTypeID(s); };
               executeAction( cTID('SplC'), undefined, DialogModes.NO );
          }
          

          • 2. Re: Auto level, split channels and save seperately.
            Paul Riggott Level 6

            You could try this..

            function main(){
            if(!documents.length) return;
            var Path = activeDocument.path;
            var origName = decodeURI(activeDocument.name);
            var Name = decodeURI(activeDocument.name).replace(/\.[^\.]+$/, '');
            activeDocument.activeLayer.autoLevels();
            executeAction( charIDToTypeID('SplC'), new ActionDescriptor(), DialogModes.NO );
            activeDocument = documents.getByName (origName+"_R");
            var saveFile = File(Path + "/"+ Name+"_red.jpg");
            SaveJPEG(saveFile, 8);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            activeDocument = documents.getByName (origName+"_G");
            var saveFile = File(Path + "/"+ Name+"_green.jpg");
            SaveJPEG(saveFile, 8);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            activeDocument = documents.getByName (origName+"_B");
            var saveFile = File(Path + "/"+ Name+"_blue.jpg");
            SaveJPEG(saveFile, 8);
            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
            }
            main();
            function SaveJPEG(saveFile, jpegQuality){
            jpgSaveOptions = new JPEGSaveOptions();
            jpgSaveOptions.embedColorProfile = true;
            jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
            jpgSaveOptions.matte = MatteType.NONE;
            jpgSaveOptions.quality = jpegQuality;
            activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
            }
            
            • 3. Re: Auto level, split channels and save seperately.
              matteotaroni

              Can you help me? I have a little variation to do for this script but i'm not able to be that.

              I have a CMYK native file in TIF format. I need split file and rename channel (ok grey scale) in:

              Cyan channel   =  Filename.C1.tif

              Magenta channel  = Filename.C2.tif

              Yellow channel = Filename.C4.tif

              Black channel = Filename.C6.tif

               

              I'll apply this script to a folder containing some tif file.

               

              Is that possible???

               

              Thank you in advance and sorry for my english.....

              Bye Matteo.

              • 4. Re: Auto level, split channels and save seperately.
                Paul Riggott Level 6

                Please try this...

                 

                function main(){
                inputFolder = Folder.selectDialog("Please select folder to process");
                if(inputFolder == null) return;
                var fileList = inputFolder.getFiles("*.tif");
                for(var a in fileList){
                open(fileList[a]);    
                if(app.activeDocument.mode != DocumentMode.CMYK) {
                    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                    continue;
                    }
                var Path = activeDocument.path;
                var origName = decodeURI(activeDocument.name);
                var Name = decodeURI(activeDocument.name).replace(/\.[^\.]+$/, '');
                activeDocument.activeLayer.autoLevels();
                executeAction( charIDToTypeID('SplC'), new ActionDescriptor(), DialogModes.NO );
                activeDocument = documents.getByName (origName+"_C");
                var saveFile = File(Path + "/"+ Name+".C1.tif");
                SaveTIFF(saveFile);
                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                activeDocument = documents.getByName (origName+"_M");
                var saveFile = File(Path + "/"+ Name+".C2.tif");
                SaveTIFF(saveFile);
                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                activeDocument = documents.getByName (origName+"_Y");
                var saveFile = File(Path + "/"+ Name+".C4.tif");
                SaveTIFF(saveFile);
                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                activeDocument = documents.getByName (origName+"_K");
                var saveFile = File(Path + "/"+ Name+".C6.tif");
                SaveTIFF(saveFile);
                app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
                }
                }
                main();
                function SaveTIFF(saveFile){
                tiffSaveOptions = new TiffSaveOptions(); 
                tiffSaveOptions.embedColorProfile = true; 
                tiffSaveOptions.alphaChannels = true; 
                tiffSaveOptions.layers = true;
                tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW; 
                activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); 
                }
                
                
                • 5. Re: Auto level, split channels and save seperately.
                  matteotaroni Level 1

                  Thank you a lot!

                  The script work great.

                  Bye, Matteo.