13 Replies Latest reply on Sep 28, 2016 7:36 AM by Loic.Aigon

    Blending Mode Issue

    tpk1982 Level 4

      Hi,

       

      I need to find the image names which apply by Multiply mode for its container (rectangle not images). The below code not finding some image even it apply with Multiply mode. May i know where it goes wrong?

       

      doc = app.activeDocument;  
      gs = doc.allGraphics;  
      var myLayersArrays = [];  
      for(i=0;i<gs.length;i++){
          p = gs[i].parent;  
       if(p.transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY){
          myLayersArrays.push(gs[i].itemLink.name);    
                  }
         } 
      alert("Images applied with applied Multiply mode: \n"+myLayersArrays.join("\n"))
      

       

       

      Thanks,

      K

        • 1. Re: Blending Mode Issue
          Loic.Aigon Adobe Community Professional

          Maybe the blendmode was set to the image itself while letting the parent to "normal" transparency setting.

           

          Did you try

           

          if(gs[i].transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY

          ||

          p.transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY){

          • 2. Re: Blending Mode Issue
            tpk1982 Level 4

            Hi Loic,

             

            Yes i checked, but strange it have normal not multiply in images itself.

             

            But my requirement is to check only the image containers. But sure i check with my client file and let you know.

             

            Thanks,

            K

            • 3. Re: Blending Mode Issue
              tpk1982 Level 4

              Hi Loic,

               

              I tested with client file, but it is not found.

               

              But i found a strange thing. If i tried to delete empty frames, then the image also deleted. Not sure what it means. But it contains image.

               

              var myGraphicFrames = app.activeDocument.rectangles; 
              for (i=myGraphicFrames.length-1; i>=0; i--) { 
                  if (myGraphicFrames[i].graphics.length < 1) 
                      myGraphicFrames[i].remove(); 
              } 
              

               

              For this reasons it is not found?

               

              I tried another logic, to find all rectangles and look if it contain images then i need to look the blending mode. I succeed with doing this with below coding, but not able to get the image name.

               

              var doc   = app.documents[0];  
              var rects = doc.rectangles;  
              
              for (var i=0, len=rects.length; i < len ; i++) {  
                var rect = rects[i];  
                if (rect.hasOwnProperty("graphics")) {  
              //~     if(rect.transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY){
                      alert(rect.transparencySettings.blendingSettings.blendMode)
                      }
                }  
              

               

              Thanks,

              K

              • 4. Re: Blending Mode Issue
                Loic.Aigon Adobe Community Professional

                You can reach the link name through the graphic instance itemLink property:

                 

                var doc   = app.documents[0];    
                var rects = doc.rectangles;    
                  var names = [];
                for (var i=0, len=rects.length; i < len ; i++) {    
                  var rect = rects[i];   
                  var g = rect.graphics[0]; //safe as long as you don't request any properties other than isValid for now
                  if (  g.isValid 
                  && 
                  rect.transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY
                  ) {
                  names [ names.length ] =  g.itemLink.name;
                  } 
                  } 
                
                
                alert( names );
                
                1 person found this helpful
                • 5. Re: Blending Mode Issue
                  tpk1982 Level 4

                  Thanks Loic. May i know the answer for question 1.Screen Shot 2016-09-28 at 2.25.37 PM.png

                   

                  This is the main problem for me. So that the original coding is not working.

                  • 6. Re: Blending Mode Issue
                    Loic.Aigon Adobe Community Professional

                    I am not sure to follow you. If you remove the frame then the image is gone for sure. A frame is a container so no misteries here. And the link instance will also be removed of course.

                    • 7. Re: Blending Mode Issue
                      tpk1982 Level 4

                      Yes ofcourse, but the coding i used only to delete empty frames, so asked.

                      • 8. Re: Blending Mode Issue
                        Loic.Aigon Adobe Community Professional

                        Oh sorry if I misunderstood you. Ok so normally any placed "image" creates a graphic instance. But as you declared you can see an "image" and yet the graphics.length return 0 so your frame is collected. So I thought what could be possibly being in that frame that couldn't be a graphic instance given that graphic is the top most class for placed images…

                        Then I realized it might be placed pageItems like you would do a paste into command. I don't know if it's the answer to your problem but you could try this :

                         

                        var doc   = app.documents[0];      
                        var rects = doc.rectangles;      
                          var names = [];  
                        for (var i=0, len=rects.length; i < len ; i++) {      
                          var rect = rects[i];     
                          var g = rect.graphics[0]; //safe as long as you don't request any properties other than isValid for now  
                          var pi = rect.pageItems[0];
                          if (  
                          (  
                          g.isValid   
                          ||
                          pi.isValid 
                          )
                          &&   
                          rect.transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY  
                          ) {  
                          names [ names.length ] =  g.isValid? g.itemLink.name : "Pasted content";  
                          }   
                          }   
                          
                          
                        alert( names ); 
                        

                         

                        HTH

                         

                        Loic

                        Ozalto | Productivity Oriented - Loïc Aigon

                        1 person found this helpful
                        • 9. Re: Blending Mode Issue
                          tpk1982 Level 4

                          Thanks Loic, unfortunately it is not working. Everything looks good with the coding but somewhat wrong with the images.

                           

                          One thing want to share, every image is placed one top of same one. Means same image placed twice on top of each other. The top one contains Multiply Mode. Bottom contains Normal mode

                           

                          The mysterious things:

                           

                          1) The image frame contains image treat as empty frame by script. So that it is not given the link name even it applied with Multiply mode.

                           

                          2) Am trying to send you the images but each one is more than 150 mb. Not sure what to do.

                           

                          If you found any solution please let me know.

                           

                          Thanks,

                          K

                          • 10. Re: Blending Mode Issue
                            Loic.Aigon Adobe Community Professional

                            I may not get something. Would you mind sharing screenshots or idml ?

                            • 11. Re: Blending Mode Issue
                              tpk1982 Level 4

                              Loic, Send PM to you

                              • 12. Re: Blending Mode Issue
                                Loic.Aigon Adobe Community Professional

                                Seen

                                • 13. Re: Blending Mode Issue
                                  Loic.Aigon Adobe Community Professional

                                  It was close. Just a check to reverse:

                                   

                                  var doc   = app.documents[0];     

                                  var rects = doc.rectangles;    

                                  var n = rects.length-1;

                                   

                                   

                                    var names = []; 

                                  for (var i=n; i >=0 ; i--) {     

                                    app.select ( rects[i] )

                                    var rect = rects[i];    

                                    var g = rect.graphics[0]; //safe as long as you don't request any properties other than isValid for now 

                                    var pi = rect.pageItems[0];

                                    if ( 

                                    ( 

                                    !g.isValid  

                                    &&

                                    !pi.isValid

                                    )

                                    &&  

                                    rect.transparencySettings.blendingSettings.blendMode == BlendMode.MULTIPLY 

                                    ) { 

                                     rect.remove();

                                    }  

                                    }  

                                   

                                  Loic

                                  http://www.ozalto.com/