3 Replies Latest reply on Jul 9, 2013 7:39 AM by corbingross@sanmar.com

    New to scripting. Need help with a >3000px-resize-but-<3000px-do-nothing script


      Hey, all. I'm new to this scripting thing. In fact, I didn't even know it existed until a few minutes ago when I started searching the googles for an answer to my resizing issues.


      I have some expierence writing expressions in AE, but very basic...


      I'd like to incorporate some sort of script into an action to resize any images over 3000px on a side to max 3000px, but leave any smaller images alone. I've found lots of examples of resizing scripts but don't understand enough about the language to rewrite them for my purposes.


      Thanks for the patience and any help you can offer!

        • 1. Re: New to scripting. Need help with a >3000px-resize-but-<3000px-do-nothing script
          Ghoulfool Level 1

          This script will do what you want:

          // pref pixels
          app.preferences.rulerUnits = Units.PIXELS;
          // call the source document
          var srcDoc = app.activeDocument;
          // get original width and height
          var imageWidth = srcDoc.width.value;
          var imageHeight = srcDoc.height.value;
          //set max size
          var maxSize = 3000;
          // vegetables
          var resizeRes = 72;
             if (Math.abs(imageWidth > imageHeight))
                if (imageWidth > maxSize)
                   scaleWithStyle(maxSize, true, "Wdth")
                if (imageHeight > maxSize)
                   scaleWithStyle(maxSize, true, "Hght")
          // function scale with style ()
          // ----------------------------------------------------------------------------
          function scaleWithStyle(input, style, widthOrHeight)
             // =======================================================
             var id01 = charIDToTypeID( "ImgS" );
             var desc = new ActionDescriptor();
             var id02 = charIDToTypeID( widthOrHeight ); // "Wdth" or "Hght" 
             var id03 = charIDToTypeID( "#Pxl" );
             desc.putUnitDouble( id02, id03, input );
             var id04 = stringIDToTypeID( "scaleStyles" ); //scale styles
             desc.putBoolean( id04, style );        //scale styles
             var id05 = charIDToTypeID( "CnsP" );   // constrain proportions
             desc.putBoolean( id05, true );      // constrain proportions
             var id06 = charIDToTypeID( "Intr" );
             var id07 = charIDToTypeID( "Intp" );
             var id08 = charIDToTypeID( "Bcbc" );
             desc.putEnumerated( id06, id07, id08 );
             executeAction( id01, desc, DialogModes.NO );
          • 2. Re: New to scripting. Need help with a >3000px-resize-but-<3000px-do-nothing script
            Michael L Hale Level 5

            The menu item File - Automate - Fit Image... has an option not to enlarge. It will do what you want and can be recorded in an action.

            • 3. Re: New to scripting. Need help with a >3000px-resize-but-<3000px-do-nothing script
              corbingross@sanmar.com Level 1

              Thanks, all! And to think, there was a menu item for this all alongh.