4 Replies Latest reply on Mar 20, 2011 8:41 PM by PS_Burner

    Cropping Question

    PS_Burner Level 1


      Don't quite follow the cropping logic. Assume my document is 600px by 900px at 120px/inch, and after putting a stream of 16pt text across the area, I initiate the following command:




      app.activeDocument.crop (new Array(25,25,550,850), 0, 600-25, 900-25);




      The "bounds," or the "new Array(25,25,550,850)" argument part of the statement, according to the Java Scripting Reference, is supposed to be "an array of four coordinates for the region remaining after cropping, [left, top, right, bottom]." However, and I realize this might be a stupid question, why is the resulting document 575px by 875px, with 25px cut off all four sides, with the resolution remaining at 120px/inch? Is the "550, 850" argument part of the bounds array argument really superfluous numbers?




      BTW, I also tried "550, 850" in place of the width and height ("600-25, 900-25") numbers in the original statement, resulting in a 550px by 850px document at a resolution of 120px/inch with 25px cut off the top and left sides, and 50px off the right and bottom.

        • 1. Re: Cropping Question
          Michael L Hale Level 5

          I think the guide may have confused you. The bounds in the crop defines what part of the original image you want to keep. You can use the bounds alone to define the crop. If you supply the width and height arguments Photoshop will also resize the document as well as crop.


          But the DOM crop method does not change the document's resolution.

          • 2. Re: Cropping Question
            PS_Burner Level 1

            Yes, the optional width and height parameters do indeed resize. You know your stuff. That was the confusion -- the Reference wasn't too clear on that. Now, I understand. Seems odd, though, not to have a resolution option (or change because of the crop as it does in real life). One of the scripts I downloaded tacked on a resolution parameter after the width and height, but it had no effect, of course. BTW, Adobe Reader X has a few bugs on my my machine, so I can't move around the Reference Manual within 15 or 20 minutes of opening a document -- it freezes up. Not worried about it as I'm sure that'll be straightened out soon.

            Thank you Michael. With your help and the help of others, I might just figure this script business out.

            • 3. Re: Cropping Question
              Michael L Hale Level 5

              You can use the scriptlistener plug-in to make a crop function that has all the options of the crop tool in the GUI.


              However, if you do use the DOM crop method then resize after the crop with document.resizeImage() you can control the resample method in addition to the width,height, and resolution.

              1 person found this helpful
              • 4. Re: Cropping Question
                PS_Burner Level 1

                This gets interestinger and interestinger. Installed Listener, did a crop, and immediately learned a bunch of new codes from the log file. Like recording macros for VBA, there's a lot of stuff in there. Just need time to write a general case from the specific steps.Thanks for the heads up Michael. You ever work with APIs with scripts? I've worked with APIs in C++ and VB, and know the two handle strings and numbers slightly differently -- especially strings. Wondered if JavaScript was different yet.