5 Replies Latest reply on Nov 16, 2012 4:03 AM by rajnikids

    Resizing images

    rajnikids Level 1

      Hi everybody!

       

      I do have script for resizing the selected images to the specified size in script.

       

      app.selection[0].verticalScale=60;

      app.selection[0].horizontalScale=60;

       

      I am trying to apply a script..

      to resize all the placed images at different scalings to 100% scaling proportionally, instead selecting the image as the above script do.

       

      Can any one help on my request.

       

      thanks.

      rkids.

        • 1. Re: Resizing images
          fabianmoronzirfas Level 1

          try something like this: 

           

          var all = app.activeDocument.allGraphics;

          var count = 0;

          while(count < all.length){

              if(all[count].imageTypeName =='JPEG'){

                   all[count].verticalScale=60; 

                  all[count].horizontalScale=60; 

             }   

          count++; 

          }

          • 2. Re: Resizing images
            rajnikids Level 1

            Super Fab, thanks,

             

            It works now. I tried adding other formats to the condition.

             

            var all = app.activeDocument.allGraphics;

            var count = 0;

             

            while(count < all.length){

             

                if(all[count].imageTypeName =='EPS', 'JPEG', 'TIFF', 'BMP'){

             

                      all[count].verticalScale=100;

             

                    all[count].horizontalScale=100;

             

               }  

              count++;

             

            }

             

            it seems, the frames still remains in the same width and I have to applypple+altC manually to fit the frame to enlarged content.

             

            Any possible way to do that.

            • 3. Re: Resizing images
              fabianmoronzirfas Level 1

              try this:

               

              var all = app.activeDocument.allGraphics;

              var count = 0;

               

              while(count < all.length){

               

              var type = all[count].imageTypeName;

                  if((type =='EPS') || (type =='JPEG')||(type == 'TIFF')||(type == 'BMP')||(type == 'TIF')){

               

                        all[count].verticalScale=100;

                        all[count].horizontalScale=100;

                       // have a look at this

                      // http://jongware.mit.edu/idcs6js/pc_Graphic.html#fit

                      all[count].fit(FitOptions.FRAME_TO_CONTENT);

                 } 

                count++;

               

              }

               

              You should get some practise with javascript basics. Have a look at http://www.codecademy.com/#!/exercises/0

               

              Cheers

               

              :fab

              • 4. Re: Resizing images
                [Jongware] Most Valuable Participant

                rajnikids wrote:

                 

                    if(all[count].imageTypeName =='EPS', 'JPEG', 'TIFF', 'BMP'){

                 

                I second Fabian's suggestion of looking into proper Javascript syntax. This is the exact same syntactic error you made earlier.

                • 5. Re: Resizing images
                  rajnikids Level 1

                  yes,

                   

                  I am trying to correct the syntax errors.

                   

                  Cheers,

                  kids.