23 Replies Latest reply on Nov 28, 2016 2:13 AM by Oriup

    List of reduced or increased images with value

    Oriup Level 1

      Hi,

       

      Can anyone modify jongware script below:

       

      I need only those image list which is reduced or increase image size with percentage value but this script get all the image with percentage value. I do not need which image is 100%.

       

      app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; 

      list = []; 

      imgs = app.activeDocument.allGraphics; 

      unitname = getCurrentUnit(); 

      for (i=0; i<imgs.length; i++) 

      scale = roundMe(imgs[i].horizontalScale,1); 

      // some fair rounding 

      list.push (imgs[i].itemLink.name+'\t'+scale+'%'); 

      // alert (list.join('\r')); exit(); 

      defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls"); 

      if (File.fs == "Windows") 

      writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" ); 

      else 

      writeFile = defaultFile.saveDlg('Save report'); 

      if (writeFile != null) 

      if (writeFile.open("w")) 

        writeFile.encoding = "utf8"; 

        writeFile.write (list.join("\r")+"\r"); 

        writeFile.close(); 

      function roundMe(val,to) 

      var t = 1; 

      while (to-- > 0) t *= 10; 

      return Math.round(val*t)/t; 

      function getCurrentUnit () 

      switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits) 

        case MeasurementUnits.POINTS: return "pt"; 

        case MeasurementUnits.PICAS: return "pt"; 

        case MeasurementUnits.INCHES: return "in"; 

        case MeasurementUnits.INCHES_DECIMAL: return "in"; 

        case MeasurementUnits.MILLIMETERS: return "mm"; 

        case MeasurementUnits.CENTIMETERS: return "cm"; 

        case MeasurementUnits.CICEROS: return "c"; 

        case MeasurementUnits.AGATES: return "ag"; 

        default: alert ("Oh, come on!"); exit(0); 

       

      Regards,

      Sumit

        • 1. Re: List of reduced or increased images with value
          tpk1982 Level 4

          Simply add a if condition in line 9.. it will work now

           

          app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN; 
          list = []; 
          imgs = app.activeDocument.allGraphics; 
          unitname = getCurrentUnit(); 
          for (i=0; i<imgs.length; i++) 
          { 
          scale = roundMe(imgs[i].horizontalScale,1); 
          // some fair rounding 
          if(imgs[i].horizontalScale!=100){
          list.push (imgs[i].itemLink.name+'\t'+scale+'%'); }
          } 
          // alert (list.join('\r')); exit(); 
          defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls"); 
          if (File.fs == "Windows") 
          writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" ); 
          else 
          writeFile = defaultFile.saveDlg('Save report'); 
          if (writeFile != null) 
          { 
          if (writeFile.open("w")) 
          { 
            writeFile.encoding = "utf8"; 
            writeFile.write (list.join("\r")+"\r"); 
            writeFile.close(); 
          } 
          } 
          function roundMe(val,to) 
          { 
          var t = 1; 
          while (to-- > 0) t *= 10; 
          return Math.round(val*t)/t; 
          } 
          function getCurrentUnit () 
          { 
          switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits) 
          { 
            case MeasurementUnits.POINTS: return "pt"; 
            case MeasurementUnits.PICAS: return "pt"; 
            case MeasurementUnits.INCHES: return "in"; 
            case MeasurementUnits.INCHES_DECIMAL: return "in"; 
            case MeasurementUnits.MILLIMETERS: return "mm"; 
            case MeasurementUnits.CENTIMETERS: return "cm"; 
            case MeasurementUnits.CICEROS: return "c"; 
            case MeasurementUnits.AGATES: return "ag"; 
            default: alert ("Oh, come on!"); exit(0); 
          } 
          } 
          
          1 person found this helpful
          • 2. Re: List of reduced or increased images with value
            Oriup Level 1

            Thank you so much!

            • 3. Re: List of reduced or increased images with value
              Laubender Adobe Community Professional & MVP

              Don't forget that there is also a vertical scale value.

              And that could be a different to the horizontal one.


              And how about skewd images?

              ( shearAngle )

               

              Regards,
              Uwe

              • 4. Re: List of reduced or increased images with value
                Oriup Level 1

                Thank you Laubender,

                 

                Yes, you are right.

                 

                Can you do that?

                 

                Kind Regards,

                Sumit

                • 5. Re: List of reduced or increased images with value
                  Oriup Level 1

                  Dear TPK,

                   

                  Can you help me?

                   

                  How to right in this forum as a script format as you write?

                   

                  Kind Regards,

                  Sumit

                  • 6. Re: List of reduced or increased images with value
                    tpk1982 Level 4

                    Hi Sumit,

                     

                    Here is the version with vertical scale value..

                     

                    app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;   
                    list = [];   
                    imgs = app.activeDocument.allGraphics;   
                    unitname = getCurrentUnit();   
                    for (i=0; i<imgs.length; i++)   
                    {   
                    scale = roundMe(imgs[i].horizontalScale,1);   
                    vscale = roundMe(imgs[i].verticalScale,1);   
                    
                    
                    // some fair rounding   
                    if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100)){  
                    list.push (imgs[i].itemLink.name+'\t'+scale+'%'+'\t'+vscale+'%'); }  
                    }   
                    // alert (list.join('\r')); exit();   
                    defaultFile = new File (Folder.myDocuments+"/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls");   
                    if (File.fs == "Windows")   
                    writeFile = defaultFile.saveDlg( 'Save report', "Plain text file:*.txt;All files:*.*" );   
                    else   
                    writeFile = defaultFile.saveDlg('Save report');   
                    if (writeFile != null)   
                    {   
                    if (writeFile.open("w"))   
                    {   
                      writeFile.encoding = "utf8";   
                      writeFile.write (list.join("\r")+"\r");   
                      writeFile.close();   
                    }   
                    }   
                    function roundMe(val,to)   
                    {   
                    var t = 1;   
                    while (to-- > 0) t *= 10;   
                    return Math.round(val*t)/t;   
                    }   
                    function getCurrentUnit ()   
                    {   
                    switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits)   
                    {   
                      case MeasurementUnits.POINTS: return "pt";   
                      case MeasurementUnits.PICAS: return "pt";   
                      case MeasurementUnits.INCHES: return "in";   
                      case MeasurementUnits.INCHES_DECIMAL: return "in";   
                      case MeasurementUnits.MILLIMETERS: return "mm";   
                      case MeasurementUnits.CENTIMETERS: return "cm";   
                      case MeasurementUnits.CICEROS: return "c";   
                      case MeasurementUnits.AGATES: return "ag";   
                      default: alert ("Oh, come on!"); exit(0);   
                    }   
                    }   
                    
                    1 person found this helpful
                    • 7. Re: List of reduced or increased images with value
                      tpk1982 Level 4

                      For script format.. use like below

                       

                      Untitled.png

                      2 people found this helpful
                      • 8. Re: List of reduced or increased images with value
                        Oriup Level 1

                        Thank you so much!

                        • 9. Re: List of reduced or increased images with value
                          Oriup Level 1

                          Dear TPK,

                           

                          Can I open, save report automatically?

                           

                          Sumit

                          • 10. Re: List of reduced or increased images with value
                            tpk1982 Level 4

                            like below?

                             

                            app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;     
                            list = [];     
                            imgs = app.activeDocument.allGraphics;     
                            unitname = getCurrentUnit();     
                            for (i=0; i<imgs.length; i++)     
                            {     
                            scale = roundMe(imgs[i].horizontalScale,1);     
                            vscale = roundMe(imgs[i].verticalScale,1);     
                              
                              
                            // some fair rounding     
                            if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100)){    
                            list.push (imgs[i].itemLink.name+'\t'+scale+'%'+'\t'+vscale+'%'); }    
                            }     
                            defaultFile = new File (app.activeDocument.name.replace(/\.indd$/i, '')+".xls");     
                            if (defaultFile.open("w"))     
                            {     
                              defaultFile.encoding = "utf8";     
                              defaultFile.write (list.join("\r")+"\r");     
                              defaultFile.close();     
                              defaultFile.execute();
                            }     
                            function roundMe(val,to)     
                            {     
                            var t = 1;     
                            while (to-- > 0) t *= 10;     
                            return Math.round(val*t)/t;     
                            }     
                            function getCurrentUnit ()     
                            {     
                            switch (app.activeDocument.viewPreferences.horizontalMeasurementUnits)     
                            {     
                              case MeasurementUnits.POINTS: return "pt";     
                              case MeasurementUnits.PICAS: return "pt";     
                              case MeasurementUnits.INCHES: return "in";     
                              case MeasurementUnits.INCHES_DECIMAL: return "in";     
                              case MeasurementUnits.MILLIMETERS: return "mm";     
                              case MeasurementUnits.CENTIMETERS: return "cm";     
                              case MeasurementUnits.CICEROS: return "c";     
                              case MeasurementUnits.AGATES: return "ag";     
                              default: alert ("Oh, come on!"); exit(0);     
                            }     
                            }  
                            
                            • 11. Re: List of reduced or increased images with value
                              Oriup Level 1

                              Dear TPK,

                               

                              Works fine but need to save report at Desktop also.

                               

                              Regards,

                              Sumit

                              • 12. Re: List of reduced or increased images with value
                                tpk1982 Level 4

                                Change line 15 to..

                                 

                                var defaultFile = new File("~/Desktop/Report.xls"); 

                                • 13. Re: List of reduced or increased images with value
                                  tpk1982 Level 4

                                  or..

                                   

                                  var defaultFile = new File("~/Desktop/"+app.activeDocument.name.replace(/\.indd$/i, '')+".xls"); 

                                  • 14. Re: List of reduced or increased images with value
                                    Oriup Level 1

                                    Dear TPK,

                                     

                                    If you do not mind, can I ask your name please?

                                     

                                    Both of your comment is file save only, not opening automatically.

                                     

                                    Regards,

                                    Sumit

                                    • 15. Re: List of reduced or increased images with value
                                      tpk1982 Level 4

                                      HI Sumit,

                                       

                                      My name is Karthi.

                                       

                                      Using    defaultFile.execute();  is to open the xls file automatically after you ran the script...

                                       

                                      Just close the excel and try again

                                      • 16. Re: List of reduced or increased images with value
                                        Oriup Level 1

                                        Dear Karthi,

                                         

                                        Thank you so much!

                                         

                                        I appreciated your reply.

                                         

                                        I have used below script:

                                         

                                         

                                        app.activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;       
                                        list = [];       
                                        imgs = app.activeDocument.allGraphics;       
                                        for (i=0; i<imgs.length; i++)       
                                        {       
                                        scale = roundMe(imgs[i].horizontalScale,1);       
                                        vscale = roundMe(imgs[i].verticalScale,1);       
                                            
                                        if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100)){      
                                        list.push (imgs[i].itemLink.name+'\t'+scale+'%'); }      
                                        }
                                        var fName = app.activeDocument.name.replace(/\.indd$/i, '')+".txt";
                                        defaultFile = new File ("~/Desktop/"+fName);
                                        if (defaultFile.open("w"))       
                                        {       
                                          defaultFile.encoding = "utf8";       
                                          defaultFile.write (list.join("\r")+"\r");       
                                          defaultFile.close();       
                                          defaultFile.execute();  
                                        }       
                                        function roundMe(val,to)       
                                        {       
                                        var t = 1;       
                                        while (to-- > 0) t *= 10;       
                                        return Math.round(val*t)/t;       
                                        }
                                        

                                         

                                         

                                        Sumit

                                        • 17. Re: List of reduced or increased images with value
                                          Oriup Level 1

                                          Dear Karthi,

                                           

                                          When I use below line, that is not working.

                                           

                                          Can you tell me what I am doing wrong?

                                           

                                          if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100) || (imgs[i].imageTypeName != "PDF")){ 
                                          

                                           

                                          If I use EPS or JPEG then working but When I use PDF then not working.

                                           

                                           

                                          Sumit

                                          • 18. Re: List of reduced or increased images with value
                                            tpk1982 Level 4

                                            Hi..

                                             

                                            In your if condition you ignored the image type of PDF if comes.. So only you not get any results..try like below

                                             

                                            if((imgs[i].imageTypeName == "PDF")){   \\ hope you know the difference of this != "PDF".. not sure why you check this

                                             

                                             

                                            if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100)){  

                                            • 19. Re: List of reduced or increased images with value
                                              Oriup Level 1

                                              Dear Karthi,

                                               

                                              I do not want to reduced pdf list because, In my document I have used pdf as a mini in teacher edition.

                                               

                                              Same condition working with eps, ai and jpeg but not working with pdf only.

                                               

                                              Sumit

                                              • 20. Re: List of reduced or increased images with value
                                                tpk1982 Level 4

                                                better try like

                                                if(imgs[i].imageTypeName == "PDF"){continue;}
                                                
                                                if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100){
                                                

                                                 

                                                also like below

                                                 

                                                 

                                                if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100) || (imgs[i].imageTypeName != "Adobe PDF")){   
                                                

                                                 

                                                or

                                                 

                                                if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100) || (imgs[i].imageTypeName !== "PDF")){   
                                                
                                                1 person found this helpful
                                                • 21. Re: List of reduced or increased images with value
                                                  Oriup Level 1

                                                  Dear Karthi,

                                                   

                                                  Thank you so much!

                                                   

                                                  Today, I learned from you "PDF" is not working but "Adobe PDF" is working.

                                                   

                                                  Below code working nicely.

                                                   

                                                  if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100) || (imgs[i].imageTypeName != "Adobe PDF")){
                                                  
                                                  

                                                   

                                                   

                                                  But, Now problem is: Adobe PDF also escape .ai file. I need escape only .pdf file.

                                                   

                                                   

                                                   

                                                   

                                                  Regards

                                                  Sumit

                                                  • 22. Re: List of reduced or increased images with value
                                                    tpk1982 Level 4

                                                    HI..

                                                     

                                                    this maybe a solution.. try and let me know

                                                     

                                                    if(app.activeDocument.allGraphics[i].itemLink.name.match(/\.pdf$/i) != null) {continue;}
                                                    if((imgs[i].horizontalScale!=100) ||(imgs[i].verticalScale!=100)){
                                                    
                                                    • 23. Re: List of reduced or increased images with value
                                                      Oriup Level 1

                                                      Dear Karthi,

                                                       

                                                      Yes, your code is working nicely.

                                                       

                                                      You are great.

                                                       

                                                      Thank you so much.

                                                       

                                                      Sumit