1 Reply Latest reply on Oct 18, 2015 10:14 PM by natrev

    [Javascript] Opening two images, and loading channels from one to the other. Works at home on PC, but not on MAC at work.

    jimmyboybadcoderlol

      Okay so, it works perfectly fine on my PC at home, but when I load the script at work (On a Mac) it gets up to the point where it opens the two images, but then at the LOAD SELECTION part, it won't recognize that there are two images open and let me load from the other one.

       

      Even stopping the script at that point and trying to select LOAD SELECTION won't work. If I open them manually (Without a script) it seems to recognize things fine and give me the load selection option, so I am confused as to what exactly is going on. Are the images just opening up too quickly and PS is freaking out or something?

        • 1. Re: [Javascript] Opening two images, and loading channels from one to the other. Works at home on PC, but not on MAC at work.
          natrev Level 3

          Hi jimmy,

           

          Please find the code...

           

          if(app.documents.length>1){

              var docRef = app.activeDocument

              var channelIndex = 0

              var visibleChannelCount = 0

              switch (docRef.mode) {

                  case DocumentMode.BITMAP:

                  case DocumentMode.GRAYSCALE:

                  case DocumentMode.INDEXEDCOLOR:

                  visibleChannelCount = 1

                  break;

                  case DocumentMode.DUOTONE:

                  visibleChannelCount = 2

                  break;

                  case DocumentMode.RGB:

                  case DocumentMode.LAB:

                  visibleChannelCount = 3

                  break;

                  case DocumentMode.CMYK:

                  visibleChannelCount = 4

                  break;

                  case DocumentMode.DUOTONE:

                  visibleChannelCount = 4

                  break;

                  case DocumentMode.MULTICHANNEL:

                  default:

                  visibleChannelCount = inDocument.channels.length + 1

                  break;

              }

          var activeChannels = app.activeDocument.activeChannels;

          var myChannels = docRef.channels;

          var selAlpha;

           

           

          var Fname=prompt("Enter the File Name with extension...!","","Do Smart") // With extension ex: Sample.psd

          //Make sure both document are same pixel dimention.!!!

          if(Fname!="") {

              for (var channelIndex = visibleChannelCount; channelIndex < myChannels.length; channelIndex++) {

                      selAlpha=docRef.channels.getByName(myChannels[channelIndex].name);

                      theCopy=app.documents.getByName(Fname);

                      selAlpha.duplicate(theCopy);

                    }//For Loop

              } //IF lopp

          }//Main loop