6 Replies Latest reply: Mar 27, 2012 5:35 AM by Wight-Walker RSS

    LongSideResize.jsx not working correctly

    Wight-Walker Community Member

      I downloaded this script from Adobe which I've used in CS5 as batch process to resize all files from 1631x1080 down to longside of 900px i.e 900x596.

       

      Using the same script in CS6 beta actually increases the size considerably i.e 25512x16893 from 1631x1080.

       

      Any ideas?

        • 1. Re: LongSideResize.jsx not working correctly
          R_Kelly Community Member

          Do you have a link to the script?

          • 2. Re: LongSideResize.jsx not working correctly
            Wight-Walker Community Member

            You'll find the download @ http://www.adobe.com/cfusion/exchange/index.cfm?event=dl&extid=1044732

             

             

            Here's the code:

             

              if (!app.documents.length > 0) {

               alert("No active document");

              }

              else {

                //Change this value to how long you would like the longest side to be

            var longSide = 500;

               var docRef = app.activeDocument;

               var docWidth = docRef.width.as("px");

               var docHeight = docRef.height.as("px");

              

               //if image is horizontal, resize with width being biggest parameter

               if (docWidth > docHeight)

               {

                var multiplier = longSide/docWidth;

              docRef.resizeImage(longSide, docHeight*multiplier, 72, ResampleMethod.BICUBIC );

               }

               else

               {

                var multiplier = longSide/docHeight;

                docRef.resizeImage(docWidth*multiplier, longSide, 72, ResampleMethod.BICUBIC );

               }

              }

             

            I slightly modified the code to allow images greater that 1900px to be left at their default size:

             

                 //Change this value to how long you would like the longest side to be
            var longSide = 900;
               var docRef = app.activeDocument;
               var docWidth = docRef.width.as("px");
               var docHeight = docRef.height.as("px");

            if (docWidth > 1900) {

              }
              else {
              
               //if image is horizontal, resize with width being biggest parameter
               if (docWidth > docHeight)
               {
                var multiplier = longSide/docWidth;
              docRef.resizeImage(longSide, docHeight*multiplier, 72, ResampleMethod.BICUBICSHARPER );
               }
               else
               {
                var multiplier = longSide/docHeight;
                docRef.resizeImage(docWidth*multiplier, longSide, 72, ResampleMethod.BICUBICSHARPER );
               }
              }

             

            Both scripts resize UP in CS6 beta whereas in CS5 they resize DOWN correctly to 900x900.

            • 3. Re: LongSideResize.jsx not working correctly
              R_Kelly Community Member

              In cs6 try setting your ruler units to pixels and see if the scripts work.

               

              If they do then add these lines to the top of the script:

               

              var originalUnit = app.preferences.rulerUnits;

              app.preferences.rulerUnits = Units.PIXELS;

               

              And add this line to the bottom of the script:

               

              app.preferences.rulerUnits = originalUnit;

               

               

               

               

              Also you can use the File>Scripts> Image Processor or Automate>Fit Image to do the same thing.

              • 4. Re: LongSideResize.jsx not working correctly
                Wight-Walker Community Member

                Thanks, that works perfectly.

                 

                I don't think that using the Image Processor would help.

                 

                As part of editing imges for web publishing, I initially create post processed images that fit the resolution of my monitor, this mixture of images i.e. portrait (1080x1631), landscape (1631x1080) & panoramic (1920xwhatever) are then further reduced to portrait (596x900), landscape (900x596) & panoramic (1920xwhatever) at reduced file size.

                 

                This simple script file allows me to include it in a batch process that handles the mixture of sizes.

                • 5. Re: LongSideResize.jsx not working correctly
                  R_Kelly Community Member

                  If for example you wanted to resize the images with the long side at 900 px, using Automate>Fit Image you would enter 900 into both fields.

                   

                   

                  Untitled-3.png

                   

                  And for the image processor it would be the same:

                   

                   

                  Untitled-7.png

                  • 6. Re: LongSideResize.jsx not working correctly
                    Wight-Walker Community Member

                    Have used this & it works fine on images that are 'x' by 'y' and/or 'y' by 'x' but the script files also allows me process a 3rd size differently in just the one process.