4 Replies Latest reply on Apr 10, 2013 2:09 PM by pigulici

    Hi, question about resize images shortest side

    pigulici Level 1

      Hi, I have PS ext CS6 64b on win 7 pc, I have more images files(psd), I want after finish to edit all, to automatic flatern psd files, change the size of each image to 1000px on shortest side(are landscape and portrait images), and save as jpg at 100% quality;I know how to use batch function in PS, I know to make this for folders with images with only width being shortest side or only for folders with height being the shortest side, but the problem it is that images are mixed ,even in the same folder, so , I must make a batch that open the file, ftattern the image, and run the script who will determine who it is the shortest side(width or height) then, resize to 1000px for shortest side, and save to jpg with 100% quality, and close the image.

      The script I think it is like this:

      if (width < height)

      resize width 1000

      else

      resize height 1000

      But I am not good at all on coding, so I ask here for help, how can I do it?

        • 1. Re: Hi, question about resize images shortest side
          Mark Ashton

          Hey,

           

          Something like this should do the trick for detecting whether to scale height or width;

           

           

          var docRef = activeDocument;

           

           

          var thewidth = docRef.width;

          var theheight = docRef.height;

           

           

          if (thewidth < theheight){

             

              docRef.resizeImage (1000, null,);

              }

           

           

          else{

             

              docRef.resizeImage (null, 1000);

              }

           

           

           

          Hope it helps

          • 2. Re: Hi, question about resize images shortest side
            pigulici Level 1

            Hmm, something it is wrong, when I creat the action, I give new action, open file, flatern image, I give File>scripts>browse, select the file with your content, and give me error "Error 8800..scratch disk are full...Line 8:docRef.ResizeImage(null,1000);", and yes the scratch disk it is up from 600mb to 55GB when this error it is happening(same error even if I not using the action , just run the script)...

            • 3. Re: Hi, question about resize images shortest side
              Mark Ashton Level 1

              apologies, I forgot to check if your settings are in pixels. Try this;

               

               

               

              var strtRulerUnits = app.preferences.rulerUnits;

              var strtTypeUnits = app.preferences.typeUnits;

              app.preferences.rulerUnits = Units.PIXELS;

              app.preferences.typeUnits = TypeUnits.PIXELS;

               

               

               

               

              var docRef = activeDocument;

               

               

              var thewidth = docRef.width;

              var theheight = docRef.height;

               

               

              if (thewidth < theheight){

                 

                  docRef.resizeImage (1000, null,);

                  }

               

               

              else{

                 

                  docRef.resizeImage (null, 1000);

                  }

               

              • 4. Re: Hi, question about resize images shortest side
                pigulici Level 1

                Yes , it is working, thank you, I must start to learn java(also at line"docRef.resizeImage (1000, null,);" it is a "," after null, I deleted to work).