@HeyoThere – Try this script:
/*
Create Frame Around Layer Image.jsx
v1.1 - 15th October 2023, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-do-i-automatically-create-a-shape-frame-around-an-image/td-p/14157861
Info: This script will add a layer group and a black/white/black frame around the target layer
*/
var origRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var layerBounds = activeDocument.activeLayer.bounds;
makeGroupFromLayers(activeDocument.activeLayer.name + " Frame");
makeRectangleShapeLayer(0, 0, 0, true, false, 53, 0, 0, 0);
activeDocument.activeLayer.name = "Black Double Stroke Frame"
makeRectangleShapeLayer(0, 0, 0, true, false, 33, 255, 255, 255);
activeDocument.activeLayer.name = "White Fill Frame"
app.preferences.rulerUnits = origRulerUnits;
///// FUNCTIONS /////
function makeRectangleShapeLayer(fillR, fillG, fillB, strokeEnabled, fillEnabled, strokeValue, strokeR, strokeG, strokeB) {
var idmake = stringIDToTypeID( "make" );
var desc238 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref28 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
ref28.putClass( idcontentLayer );
desc238.putReference( idnull, ref28 );
var idusing = stringIDToTypeID( "using" );
var desc239 = new ActionDescriptor();
var idtype = stringIDToTypeID( "type" );
var desc240 = new ActionDescriptor();
var idcolor = stringIDToTypeID( "color" );
var desc241 = new ActionDescriptor();
var idred = stringIDToTypeID( "red" );
desc241.putDouble( idred, fillR );
var idgrain = stringIDToTypeID( "grain" );
desc241.putDouble( idgrain, fillG );
var idblue = stringIDToTypeID( "blue" );
desc241.putDouble( idblue, fillB );
var idRGBColor = stringIDToTypeID( "RGBColor" );
desc240.putObject( idcolor, idRGBColor, desc241 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc239.putObject( idtype, idsolidColorLayer, desc240 );
var idshape = stringIDToTypeID( "shape" );
var desc242 = new ActionDescriptor();
var idunitValueQuadVersion = stringIDToTypeID( "unitValueQuadVersion" );
desc242.putInteger( idunitValueQuadVersion, 1 );
var idtop = stringIDToTypeID( "top" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idtop, idpixelsUnit, layerBounds[1].value );
var idleft = stringIDToTypeID( "left" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idleft, idpixelsUnit, layerBounds[0].value );
var idbottom = stringIDToTypeID( "bottom" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idbottom, idpixelsUnit, layerBounds[3].value );
var idright = stringIDToTypeID( "right" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idright, idpixelsUnit, layerBounds[2].value );
var idtopRight = stringIDToTypeID( "topRight" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idtopRight, idpixelsUnit, 0.000000 );
var idtopLeft = stringIDToTypeID( "topLeft" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idtopLeft, idpixelsUnit, 0.000000 );
var idbottomLeft = stringIDToTypeID( "bottomLeft" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idbottomLeft, idpixelsUnit, 0.000000 );
var idbottomRight = stringIDToTypeID( "bottomRight" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc242.putUnitDouble( idbottomRight, idpixelsUnit, 0.000000 );
var idrectangle = stringIDToTypeID( "rectangle" );
desc239.putObject( idshape, idrectangle, desc242 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
var desc243 = new ActionDescriptor();
var idstrokeStyleVersion = stringIDToTypeID( "strokeStyleVersion" );
desc243.putInteger( idstrokeStyleVersion, 2 );
var idstrokeEnabled = stringIDToTypeID( "strokeEnabled" );
desc243.putBoolean( idstrokeEnabled, strokeEnabled );
var idfillEnabled = stringIDToTypeID( "fillEnabled" );
desc243.putBoolean( idfillEnabled, fillEnabled );
var idstrokeStyleLineWidth = stringIDToTypeID( "strokeStyleLineWidth" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc243.putUnitDouble( idstrokeStyleLineWidth, idpixelsUnit, strokeValue );
var idstrokeStyleLineDashOffset = stringIDToTypeID( "strokeStyleLineDashOffset" );
var idpointsUnit = stringIDToTypeID( "pointsUnit" );
desc243.putUnitDouble( idstrokeStyleLineDashOffset, idpointsUnit, 0.000000 );
var idstrokeStyleMiterLimit = stringIDToTypeID( "strokeStyleMiterLimit" );
desc243.putDouble( idstrokeStyleMiterLimit, 100.000000 );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleLineCapType = stringIDToTypeID( "strokeStyleLineCapType" );
var idstrokeStyleButtCap = stringIDToTypeID( "strokeStyleButtCap" );
desc243.putEnumerated( idstrokeStyleLineCapType, idstrokeStyleLineCapType, idstrokeStyleButtCap );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleLineJoinType = stringIDToTypeID( "strokeStyleLineJoinType" );
var idstrokeStyleMiterJoin = stringIDToTypeID( "strokeStyleMiterJoin" );
desc243.putEnumerated( idstrokeStyleLineJoinType, idstrokeStyleLineJoinType, idstrokeStyleMiterJoin );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleLineAlignment = stringIDToTypeID( "strokeStyleLineAlignment" );
var idstrokeStyleAlignCenter = stringIDToTypeID( "strokeStyleAlignCenter" );
desc243.putEnumerated( idstrokeStyleLineAlignment, idstrokeStyleLineAlignment, idstrokeStyleAlignCenter );
var idstrokeStyleScaleLock = stringIDToTypeID( "strokeStyleScaleLock" );
desc243.putBoolean( idstrokeStyleScaleLock, false );
var idstrokeStyleStrokeAdjust = stringIDToTypeID( "strokeStyleStrokeAdjust" );
desc243.putBoolean( idstrokeStyleStrokeAdjust, false );
var idstrokeStyleLineDashSet = stringIDToTypeID( "strokeStyleLineDashSet" );
var list7 = new ActionList();
desc243.putList( idstrokeStyleLineDashSet, list7 );
var idstrokeStyleBlendMode = stringIDToTypeID( "strokeStyleBlendMode" );
var idblendMode = stringIDToTypeID( "blendMode" );
var idnormal = stringIDToTypeID( "normal" );
desc243.putEnumerated( idstrokeStyleBlendMode, idblendMode, idnormal );
var idstrokeStyleOpacity = stringIDToTypeID( "strokeStyleOpacity" );
var idpercentUnit = stringIDToTypeID( "percentUnit" );
desc243.putUnitDouble( idstrokeStyleOpacity, idpercentUnit, 100.000000 );
var idstrokeStyleContent = stringIDToTypeID( "strokeStyleContent" );
var desc244 = new ActionDescriptor();
var idcolor = stringIDToTypeID( "color" );
var desc245 = new ActionDescriptor();
var idred = stringIDToTypeID( "red" );
desc245.putDouble( idred, strokeR );
var idgrain = stringIDToTypeID( "grain" );
desc245.putDouble( idgrain, strokeG );
var idblue = stringIDToTypeID( "blue" );
desc245.putDouble( idblue, strokeB );
var idRGBColor = stringIDToTypeID( "RGBColor" );
desc244.putObject( idcolor, idRGBColor, desc245 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc243.putObject( idstrokeStyleContent, idsolidColorLayer, desc244 );
var idstrokeStyleResolution = stringIDToTypeID( "strokeStyleResolution" );
desc243.putDouble( idstrokeStyleResolution, 72.000000 );
var idstrokeStyle = stringIDToTypeID( "strokeStyle" );
desc239.putObject( idstrokeStyle, idstrokeStyle, desc243 );
var idcontentLayer = stringIDToTypeID( "contentLayer" );
desc238.putObject( idusing, idcontentLayer, desc239 );
executeAction( idmake, desc238, DialogModes.NO );
}
function makeGroupFromLayers(theName) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putClass( s2t( "layerSection" ));
descriptor.putReference( s2t( "null" ), reference );
reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( s2t( "from" ), reference2 );
descriptor2.putString( s2t( "name" ), theName );
descriptor.putObject( s2t( "using" ), s2t( "layerSection" ), descriptor2 );
executeAction( s2t( "make" ), descriptor, DialogModes.NO );
}
https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html