Copy link to clipboard
Copied
I want to create a script that can create a shape (circle, ellipse, or square) that is the same size as the text layer's stroke (e.g. 100px). Runs only on the current file.
I have combined a script to fill layer with canvas and some actions. But still have to open a new file to get the exact size. Does anyone have any better ideas?
The third argument of the function Ā»ellipseShapeLayerĀ« is the Stroke Width (3 in the code I posted), feel free to change it.
I also cannot add other effects like gradients, color overlays to this dialog.
Please explain what you mean with screenshots.
// create custom shape layer based on layer bounds including styles;
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var b1 = layerDesc.getObjectValue(stringIDToTypeID("bounds"));
var b2 = layerDesc.getObjectValue(strin
...
Copy link to clipboard
Copied
The function Ā»ellipseShapeLayerĀ« takes the Stroke Width as its third argument, which is set to 3 in the provided code. You can modify this value as needed.
Copy link to clipboard
Copied
I tried changing this parameter from 3 to 1. But the stroke became 12.5px instead of 3px.
Copy link to clipboard
Copied
To create a script that automatically creates a shape (circle, ellipse, or square) with the same size as the text layer's stroke in Photoshop and runs only on the current file, you can use the following JavaScript code. This script assumes that the text layer with the stroke is selected.
This script checks if there is an active document and if the active layer is a text layer. If conditions are met, it gets the stroke size of the text layer and creates a new shape layer (ellipse, circle, or square) with the same size. Adjust the color and shape type as needed. Save this script with a .jsx extension and run it from the Photoshop Scripts menu.
Copy link to clipboard
Copied
Thank you for the script. When I run this message appears. Btw, I'm stuck with custom shape for now...