3 Replies Latest reply on May 29, 2013 1:04 PM by jtredinn

    Marquee fixed ratio alert

    jtredinn

      Hi all,

      I'm trying to incorporate into my processing script an alert if my marquee selection is not a fixed ratio. 

      I don't want to crop my images and only want to be able to process them by my marquee selection, but want the script to catch if for some reason my marquee is not a fixed ratio of 336x596. 

       

      I've trying many different things can can't get it to catch this since my image sizes are not consistent. 

      Any help is greatly appreciated!

       

      -JT

        • 1. Re: Marquee fixed ratio alert
          pixxxel schubser MVP & Adobe Community Professional

          How is the selection made?  Has the width and height of the selection always been an integral multiple of the fixed ratio?

           

          Regardless - try something like this:

           

           

          // Sel_ratioCheck.jsx
          // http://forums.adobe.com/thread/1221655?tstart=0
          // regards pixxxelschubser
          
          var w = 336;
          var h = 596;
          
          var aDoc = app.activeDocument;
          app.preferences.rulerUnits = Units.PIXELS;
          var aSel = aDoc.selection.bounds;
          var W_factor = (aSel[2]-aSel[0])/w*1000;
          var H_factor = (aSel[3]-aSel[1])/h*1000;
          W_factor = Math.round(W_factor);
          H_factor = Math.round(H_factor);
          if (W_factor == H_factor) {
              alert ("fixed ratio of 336x596");
              } else {
                  alert("The ratio is wrong:\n"+W_factor+" : "+H_factor);
                  }
          

           

           

          However, if the existing selection is much too small, then the calculation will be incorrect.

           

           

          Have fun

          1 person found this helpful
          • 2. Re: Marquee fixed ratio alert
            jtredinn Level 1

            Thanks for your response!

            My method is:

            I work the image at full rez, make my selection with the marquee tool, and run my processor script which reads the resolution and saves to my selected sizes.  The problem I run into is when I fail to change my marquee selection back to the save fixed ratio of 336x596 before doing this.  I just want to incorporate into my script that the proportions are wrong.  I do have in place -

             

                 var docHeight = docRef.height.value;

                 var docWidth =  docRef.width.value;

             

             

                if (docHeight >= 2000 && docWidth >= 1016){// checks to see if a the width and height are large enough, asks if user would like to continue

                    docRef.resizeImage(1128, 2000, 72, ResampleMethod.BICUBIC);       

                    saveCrops("q");

                }

               

                else if (docHeight >= 1500 && docHeight < 2000){

                    docRef.resizeImage(846, 1500, 72, ResampleMethod.BICUBIC);  

                    saveCrops("q");

                   

                }

                else if (docHeight >= 1000 && docHeight < 1500){

                    docRef.resizeImage(564, 1000, 72, ResampleMethod.BICUBIC);

                    saveCrops("q");

                   

                }

                else if (docHeight >= 336 && docHeight < 596){

                    docRef.resizeImage(336, 596, 72, ResampleMethod.BICUBIC);

                    saveCrops("q");

                  

                }

             

             

            I tried incorporated what you gave me and it gives me an error message..

            error2.png

             

            Again, thanks for your help on this!  I'll keep working on it and appreciate any further assistance!!

            • 3. Re: Marquee fixed ratio alert
              jtredinn Level 1

              Hi pixxxel schubser...

              I fixed the error, (the w*1000 and h*1000 needed to be W and H)

              now it still catches all images because with my resolution the fixed ratio isn't being read at 336x596.  Any ideas?

              I'll keep playing with it...

              It is still working better than it was before your help