Skip to main content
Participating Frequently
November 16, 2021
Question

Parametrising an internal border

  • November 16, 2021
  • 2 replies
  • 242 views

In the absence of trying to create a "border" line to an image in light room where the border is actually just inside the edge of the image that apparently, according to another forum post can't be done, is there a way to parameterise this as an action in PS.

 

so instead of having to go through the process manually each time for images of variable dimensions it will look at the image height and width and instead of committing to xpixels it will do x%.

 

so if an image is 3000x4000 then the line is say 30 pixels wide and positioned 100 pixels inside the outer edge whilst if the image is 300x400 it sets this to 3 pixels wide and 10 pixels inside the outer edge?

This topic has been closed for replies.

2 replies

c.pfaffenbichler
Community Expert
Community Expert
November 17, 2021

I suspect this would need a Script instead of an Action. 

LaslettAuthor
Participating Frequently
November 17, 2021

Do you know where I can find some script guide that might come close to this that I can adopt?

c.pfaffenbichler
Community Expert
Community Expert
November 17, 2021

 

// 2021, use it at your own risk;
if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
// set to pixels;
    var originalRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
// get dimensions;
    var theWidth = myDocument.width;
    var theHeight = myDocument.height;
    var theOffset = theWidth*0.0333333;
    var theStroke = theWidth*0.01;
    myDocument.selection.select([[theOffset, theOffset], [theWidth-theOffset, theOffset], [theWidth-theOffset, theHeight-theOffset], [theOffset, theHeight-theOffset]], SelectionType.REPLACE, 0, false)
    myDocument.selection.select([[theOffset+theStroke, theOffset+theStroke], [theWidth-theOffset-theStroke, theOffset+theStroke], [theWidth-theOffset-theStroke, theHeight-theOffset-theStroke], [theOffset+theStroke, theHeight-theOffset-theStroke]], SelectionType.DIMINISH, 0, false)
    createSolidColorLayer (0, 0, 0);
// reset;
    app.preferences.rulerUnits = originalRulerUnits;
};
////// make solid color layer //////
function createSolidColorLayer (theRed, theGreen, theBlue) {
// create solid color layer;
// =======================================================
    var idMk = charIDToTypeID( "Mk  " );
        var desc8 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref6 = new ActionReference();
            var idcontentLayer = stringIDToTypeID( "contentLayer" );
            ref6.putClass( idcontentLayer );
        desc8.putReference( idnull, ref6 );
        var idUsng = charIDToTypeID( "Usng" );
            var desc9 = new ActionDescriptor();
            var idType = charIDToTypeID( "Type" );
                var desc10 = new ActionDescriptor();
                var idClr = charIDToTypeID( "Clr " );
                    var desc11 = new ActionDescriptor();
                    var idRd = charIDToTypeID( "Rd  " );
                    desc11.putDouble( idRd, theRed );
                    var idGrn = charIDToTypeID( "Grn " );
                    desc11.putDouble( idGrn, theGreen );
                    var idBl = charIDToTypeID( "Bl  " );
                    desc11.putDouble( idBl, theBlue );
                var idRGBC = charIDToTypeID( "RGBC" );
                desc10.putObject( idClr, idRGBC, desc11 );
            var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
            desc9.putObject( idType, idsolidColorLayer, desc10 );
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        desc8.putObject( idUsng, idcontentLayer, desc9 );
    executeAction( idMk, desc8, DialogModes.NO );
    return activeDocument.activeLayer
    };

 

Rob_Cullen
Community Expert
Community Expert
November 16, 2021

Moderator- Please transfer this post to the 'Photoshop' Community forum.

Regards. My System: Windows-11, Lightroom-Classic 15.3, Photoshop 27.5, ACR 18.3, Lightroom 9.3, Lr-iOS 10.4.0, Bridge 16.0.3 .