5 Replies Latest reply on Mar 3, 2013 12:11 PM by JJMack

    Action for rectangle with rounded corners

    AadMetz Level 2

      I want to create an action to apply to several images.


      This had to be the result.

      But I want to use the action for a portrait or landscape image

      or 72 or 300 dpi picture.

        • 1. Re: Action for rectangle with rounded corners
          JJMack Most Valuable Participant

          An Action for a single layer background layer.  Set your ruler units to Percent.  The set guide line Horizontal and Vertical at 10% and 90%.   Now record this action:

          Step 1 select the rounded rectangle tool set it to draw out a Path in the options bar. Then Draw out the path from the top left intersecting guides to the bottom right intersecting guides.

          Step 2 on the option bar next to Make click on Selection.  In the selection dialog 0 Feather, check anti-alias, new selection click OK.

          Step 3 Menu Select>Inverse

          Step 4 Menu Edit>Fill>Color any color you want the boarder.

          • 2. Re: Action for rectangle with rounded corners
            Paul Riggott Level 6

            This is only going to work for one size of picture and one orientation.

            A very simple script would be required to make it work on any sized document and any orientation.

            • 3. Re: Action for rectangle with rounded corners
              JJMack Most Valuable Participant

              Paul most of the time what you write is correct however not this time Here are two screen captures top has 5 different size and ratio document open in Photoshop and the action palette with the action I described recorded. The second capture you will see the results of running the action on the documents.


              • 4. Re: Action for rectangle with rounded corners
                Paul Riggott Level 6

                Thanks for that JJ, I did not realize the path was recorded using percentages, when looking at the log all the figures were in pixels not percentages.

                There will still be a problem using that  action on large documents as the corners will not look good as the action has these set to 10pixels, a script would give a more even look on any sized document I.E.



                function main(){
                if(!documents.length) return;
                var startRulerUnits = preferences.rulerUnits;
                preferences.rulerUnits = Units.PIXELS;
                var doc = activeDocument;
                //make sure landscape and portrait borders look the same
                var ShortSide = Math.min(doc.width,doc.height);
                borderPercent = ShortSide/100*6; //6 percent border
                var Left = borderPercent;
                var Top = borderPercent;
                var Right = doc.width - borderPercent;
                var Bottom = doc.height - borderPercent;
                var Radius = ShortSide/26; //size of the corners
                var workPath = doc.pathItems.getByName("Work Path").makeSelection();
                doc.pathItems.getByName("Work Path").remove();
                //remove the line below if you do not want the border on its own layer
                var White= new SolidColor();
                doc.selection.fill(White, ColorBlendMode.NORMAL, 100);
                preferences.rulerUnits = startRulerUnits;
                function setRecPath(Left,Top,Right,Bottom,Radius) {
                var desc = new ActionDescriptor();
                var ref = new ActionReference();
                ref.putProperty( charIDToTypeID('Path'), charIDToTypeID('WrPt') );
                desc.putReference( charIDToTypeID('null'), ref );
                var desc2 = new ActionDescriptor();
                desc2.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), Left );
                desc2.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), Top );
                desc2.putUnitDouble( charIDToTypeID('Rght'), charIDToTypeID('#Pxl'), Right );
                desc2.putUnitDouble( charIDToTypeID('Btom'), charIDToTypeID('#Pxl'), Bottom );
                desc2.putUnitDouble( charIDToTypeID('Rds '), charIDToTypeID('#Pxl'), Radius );
                desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Rctn'), desc2 );
                executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
                • 5. Re: Action for rectangle with rounded corners
                  JJMack Most Valuable Participant

                  Yes a script can set the top left bottom right points using pixel values and create even borders using scriptlintener code. An actuon can be recoeded that will produce even borders however the corners is the adtion would be square not rounded. Using % produce aspect ratio paths.