Copy link to clipboard
Copied
I have 5Layers, I want make Convert to Frame 5Layers ??
Here is script !!
#target photoshop
//
// ST.jsx
//
//
// Generated Tue Aug 31 2021 03:33:47 GMT+0530
//
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== ST ==============
//
function ST() {
// Make
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(sTID("framedGroupSection"));
desc1.putReference(cTID('null'), ref1);
desc1.putString(cTID('Nm '), "HFrame");
var desc2 = new ActionDescriptor();
desc2.putDouble(cTID('Top '), 1800);
desc2.putDouble(cTID('Left'), 2719);
desc2.putDouble(cTID('Btom'), 3446);
desc2.putDouble(cTID('Rght'), 5268);
desc1.putObject(sTID("framedGroupRect"), sTID("classFloatRect"), desc2);
desc1.putDouble(sTID("framedGroupPathResolution"), 300);
var desc3 = new ActionDescriptor();
var list1 = new ActionList();
var desc4 = new ActionDescriptor();
desc4.putEnumerated(sTID("shapeOperation"), sTID("shapeOperation"), cTID('Add '));
var list2 = new ActionList();
var desc5 = new ActionDescriptor();
desc5.putBoolean(cTID('Clsp'), true);
var list3 = new ActionList();
var desc6 = new ActionDescriptor();
var desc7 = new ActionDescriptor();
desc7.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2724);
desc7.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800.5);
desc6.putObject(cTID('Anch'), cTID('Pnt '), desc7);
var desc8 = new ActionDescriptor();
desc8.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2724);
desc8.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800.5);
desc6.putObject(cTID('Fwd '), cTID('Pnt '), desc8);
var desc9 = new ActionDescriptor();
desc9.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2721.238577);
desc9.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800.5);
desc6.putObject(cTID('Bwd '), cTID('Pnt '), desc9);
desc6.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc6);
var desc10 = new ActionDescriptor();
var desc11 = new ActionDescriptor();
desc11.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5263);
desc11.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800.5);
desc10.putObject(cTID('Anch'), cTID('Pnt '), desc11);
var desc12 = new ActionDescriptor();
desc12.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5265.761423);
desc12.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800.5);
desc10.putObject(cTID('Fwd '), cTID('Pnt '), desc12);
var desc13 = new ActionDescriptor();
desc13.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5263);
desc13.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1800.5);
desc10.putObject(cTID('Bwd '), cTID('Pnt '), desc13);
desc10.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc10);
var desc14 = new ActionDescriptor();
var desc15 = new ActionDescriptor();
desc15.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5268);
desc15.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1805.5);
desc14.putObject(cTID('Anch'), cTID('Pnt '), desc15);
var desc16 = new ActionDescriptor();
desc16.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5268);
desc16.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1805.5);
desc14.putObject(cTID('Fwd '), cTID('Pnt '), desc16);
var desc17 = new ActionDescriptor();
desc17.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5268);
desc17.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1802.738577);
desc14.putObject(cTID('Bwd '), cTID('Pnt '), desc17);
desc14.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc14);
var desc18 = new ActionDescriptor();
var desc19 = new ActionDescriptor();
desc19.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5268);
desc19.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3441);
desc18.putObject(cTID('Anch'), cTID('Pnt '), desc19);
var desc20 = new ActionDescriptor();
desc20.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5268);
desc20.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3443.761423);
desc18.putObject(cTID('Fwd '), cTID('Pnt '), desc20);
var desc21 = new ActionDescriptor();
desc21.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5268);
desc21.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3441);
desc18.putObject(cTID('Bwd '), cTID('Pnt '), desc21);
desc18.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc18);
var desc22 = new ActionDescriptor();
var desc23 = new ActionDescriptor();
desc23.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5263);
desc23.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3446);
desc22.putObject(cTID('Anch'), cTID('Pnt '), desc23);
var desc24 = new ActionDescriptor();
desc24.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5263);
desc24.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3446);
desc22.putObject(cTID('Fwd '), cTID('Pnt '), desc24);
var desc25 = new ActionDescriptor();
desc25.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 5265.761423);
desc25.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3446);
desc22.putObject(cTID('Bwd '), cTID('Pnt '), desc25);
desc22.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc22);
var desc26 = new ActionDescriptor();
var desc27 = new ActionDescriptor();
desc27.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2724);
desc27.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3446);
desc26.putObject(cTID('Anch'), cTID('Pnt '), desc27);
var desc28 = new ActionDescriptor();
desc28.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2721.238577);
desc28.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3446);
desc26.putObject(cTID('Fwd '), cTID('Pnt '), desc28);
var desc29 = new ActionDescriptor();
desc29.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2724);
desc29.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3446);
desc26.putObject(cTID('Bwd '), cTID('Pnt '), desc29);
desc26.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc26);
var desc30 = new ActionDescriptor();
var desc31 = new ActionDescriptor();
desc31.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2719);
desc31.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3441);
desc30.putObject(cTID('Anch'), cTID('Pnt '), desc31);
var desc32 = new ActionDescriptor();
desc32.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2719);
desc32.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3441);
desc30.putObject(cTID('Fwd '), cTID('Pnt '), desc32);
var desc33 = new ActionDescriptor();
desc33.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2719);
desc33.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 3443.761423);
desc30.putObject(cTID('Bwd '), cTID('Pnt '), desc33);
desc30.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc30);
var desc34 = new ActionDescriptor();
var desc35 = new ActionDescriptor();
desc35.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2719);
desc35.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1805.5);
desc34.putObject(cTID('Anch'), cTID('Pnt '), desc35);
var desc36 = new ActionDescriptor();
desc36.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2719);
desc36.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1802.738577);
desc34.putObject(cTID('Fwd '), cTID('Pnt '), desc36);
var desc37 = new ActionDescriptor();
desc37.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), 2719);
desc37.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 1805.5);
desc34.putObject(cTID('Bwd '), cTID('Pnt '), desc37);
desc34.putBoolean(cTID('Smoo'), true);
list3.putObject(cTID('Pthp'), desc34);
desc5.putList(cTID('Pts '), list3);
list2.putObject(cTID('Sbpl'), desc5);
desc4.putList(cTID('SbpL'), list2);
list1.putObject(cTID('PaCm'), desc4);
desc3.putList(sTID("pathComponents"), list1);
desc1.putObject(sTID("framedGroupPath"), sTID("pathClass"), desc3);
desc1.putInteger(sTID("framedGroupType"), 4);
desc1.putBoolean(sTID("LockPPI"), false);
desc1.putDouble(sTID("PreferredResolution"), 300);
desc1.putString(sTID("SavedIteratedName"), "");
executeAction(cTID('Mk '), desc1, dialogMode);
};
step1(); // Make
};
//=========================================
// ST.main
//=========================================
//
ST.main = function () {
ST();
};
ST.main();
// EOF
"ST.jsx"
// EOF
The following script will add a frame at the document bounds to all top level layers (code modifed to work in reverse layer order since the original screenshot).
/*
Add Frame To All Layers.jsx
v1.1 - Stephen Marsh, 5th August 2021
https://community.adobe.com/t5/photoshop-ecosystem-discussions/make-a-frame-all-layer-in-ps-script/td-p/12352583
Make a Frame all Layer in PS Script
*/
#target photoshop
function main() {
// Save the current ruler units and set to pixels
var savedRuler
...
Copy link to clipboard
Copied
It appears that you have converted an action to jsx using xtools.
I had a new doc created with 5 empty layers.
Your code has added a new 6th layer with a frame. I was expecting that one or more of the existing layers would be converted to a frame.
Can you provide a cropped screenshot of the layer panel, before and after so that the forum can visually understand what you are trying to achieve?
What should the frame size be? A fixed numeric value? The document size? The bounding size of layer content? Artboard size etc?
Copy link to clipboard
Copied
The following script will add a frame at the document bounds to all top level layers (code modifed to work in reverse layer order since the original screenshot).
/*
Add Frame To All Layers.jsx
v1.1 - Stephen Marsh, 5th August 2021
https://community.adobe.com/t5/photoshop-ecosystem-discussions/make-a-frame-all-layer-in-ps-script/td-p/12352583
Make a Frame all Layer in PS Script
*/
#target photoshop
function main() {
// Save the current ruler units and set to pixels
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
app.activeDocument.activeLayer = app.activeDocument.layers[app.activeDocument.layers.length - 1];
// Loop forward over top level layers
// for (var i = 0; i < app.activeDocument.layers.length; i++) {
// Loop backward over top level layers
for (var i = app.activeDocument.layers.length - 1; i >= 0; i--) {
try {
app.activeDocument.activeLayer = app.activeDocument.layers[i];
layerFrameFromDocWidthHeight(4, 5, "Frame 1", 0, 0, app.activeDocument.height.value, app.activeDocument.width.value, 1, false, 300, "");
} catch (e) { }
}
// Restore the ruler units
app.preferences.rulerUnits = savedRuler;
function layerFrameFromDocWidthHeight(layerSectionStart, layerSectionEnd, name2, top, left, bottom, right, framedGroupType, LockPPI, PreferredResolution, SavedIteratedName) {
var layerName = app.activeDocument.activeLayer.name;
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putClass(s2t("framedGroupSection"));
descriptor.putReference(s2t("null"), reference);
reference2.putName(s2t("layer"), app.activeDocument.activeLayer.name);
descriptor.putReference(s2t("from"), reference2);
descriptor.putInteger(s2t("layerSectionStart"), layerSectionStart);
descriptor.putInteger(s2t("layerSectionEnd"), layerSectionEnd);
descriptor.putString(s2t("name"), name2);
descriptor2.putDouble(s2t("top"), top);
descriptor2.putDouble(s2t("left"), left);
descriptor2.putDouble(s2t("bottom"), bottom);
descriptor2.putDouble(s2t("right"), right);
descriptor.putObject(s2t("framedGroupRect"), s2t("classFloatRect"), descriptor2);
descriptor.putInteger(s2t("framedGroupType"), framedGroupType);
descriptor.putBoolean(s2t("LockPPI"), LockPPI);
descriptor.putDouble(s2t("PreferredResolution"), PreferredResolution);
descriptor.putString(s2t("SavedIteratedName"), SavedIteratedName);
executeAction(s2t("make"), descriptor, DialogModes.NO);
app.activeDocument.activeLayer.name = layerName;
}
}
app.activeDocument.suspendHistory("Add Frame To All Layers.jsx", "main()");
EDIT: Original code updated 5th September 2021
Copy link to clipboard
Copied
Thanku so much @Stephen Marsh Perfect Working , I have seen just now because i had out of station
Copy link to clipboard
Copied
Your welcome, I took a guess so I'm glad that was what you were looking for.
Copy link to clipboard
Copied
One thing is needed @Stephen Marsh ,In this script, I want to Selected Layer make a frame layer
Copy link to clipboard
Copied
So, rather than all layers as originally requested, now it should only be for selected layers?
Copy link to clipboard
Copied
Yes, Could you send the script of Selected Layer @Stephen Marsh
Copy link to clipboard
Copied
A single selected layer is easy.
Sorry, it's going to take a more experienced scripter than me for multiple selected layers. I have spent a few hours on this without success.
Copy link to clipboard
Copied
As belatedly requested, the following code will create Frames from only selected (compatible) layers.
Standing on the shoulders of giants, in this case thanks to @jazz-y – I was able to hack the code for general use.
/*
Add Frame To Selected Layers.jsx
v1.0 - Stephen Marsh, 5th September 2021
NOTE: No error checking for a selected layer being the Background layer
https://community.adobe.com/t5/photoshop-ecosystem-discussions/make-a-frame-all-layer-in-ps-script/td-p/12352583
Make a Frame all Layer in PS Script
Code to process selected layers courtesy of jazz-y
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-can-i-remove-all-the-selected-contents-on-several-layers-at-once/m-p/12360678#M580686
How can i remove all the selected contents on several layers at once?
*/
#target photoshop
function main() {
// Save the current ruler units and set to pixels
var savedRuler = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var s2t = stringIDToTypeID;
(r = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
var lrs = executeActionGet(r).getList(p),
sel = new ActionReference();
for (var i = 0; i < lrs.count; i++) {
sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
(r = new ActionReference).putIdentifier(s2t('layer'), p);
(d = new ActionDescriptor()).putReference(s2t("target"), r);
executeAction(s2t('select'), d, DialogModes.NO);
///// Do stuff to selected layers /////
layerFrameFromDocWidthHeight(4, 5, "Frame 1", 0, 0, app.activeDocument.height.value, app.activeDocument.width.value, 1, false, 300, "");
///////////////////////////////////////
}
// Restore the ruler units
app.preferences.rulerUnits = savedRuler;
function layerFrameFromDocWidthHeight(layerSectionStart, layerSectionEnd, name2, top, left, bottom, right, framedGroupType, LockPPI, PreferredResolution, SavedIteratedName) {
var layerName = app.activeDocument.activeLayer.name;
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
var reference2 = new ActionReference();
reference.putClass(s2t("framedGroupSection"));
descriptor.putReference(s2t("null"), reference);
reference2.putName(s2t("layer"), app.activeDocument.activeLayer.name);
descriptor.putReference(s2t("from"), reference2);
descriptor.putInteger(s2t("layerSectionStart"), layerSectionStart);
descriptor.putInteger(s2t("layerSectionEnd"), layerSectionEnd);
descriptor.putString(s2t("name"), name2);
descriptor2.putDouble(s2t("top"), top);
descriptor2.putDouble(s2t("left"), left);
descriptor2.putDouble(s2t("bottom"), bottom);
descriptor2.putDouble(s2t("right"), right);
descriptor.putObject(s2t("framedGroupRect"), s2t("classFloatRect"), descriptor2);
descriptor.putInteger(s2t("framedGroupType"), framedGroupType);
descriptor.putBoolean(s2t("LockPPI"), LockPPI);
descriptor.putDouble(s2t("PreferredResolution"), PreferredResolution);
descriptor.putString(s2t("SavedIteratedName"), SavedIteratedName);
executeAction(s2t("make"), descriptor, DialogModes.NO);
app.activeDocument.activeLayer.name = layerName;
}
}
app.activeDocument.suspendHistory("Add Frame To Selected Layers.jsx", "main()");
Copy link to clipboard
Copied
Everything is fine @Stephen Marsh , But Height and Width Value Did not match according to Layer ?
Please modify the Height and Width Value ?
var theBounds = app.activeDocument.activeLayer.bounds;
var layerWidth = theBounds[2] - theBounds[0];
var layerHeight = theBounds[3] - theBounds[1];
Copy link to clipboard
Copied
The script was explicity written to apply the frame to the document bounds. You can of course modify it to suit your unspecified and or belatedly stated requirements.
I have not tested, perhaps something like:
///// Do stuff to selected layers /////
var theBounds = app.activeDocument.activeLayer.bounds;
layerFrameFromDocWidthHeight(4, 5, "Frame 1", theBounds[1], theBounds[0], theBounds[3], theBounds[2], 1, false, 300, "");
///////////////////////////////////////
Copy link to clipboard
Copied
Thanku so much @Stephen Marsh
Copy link to clipboard
Copied
anyone help to Make a Frame all Layer in PS Scriptx with retain effects of layers like shadow border etc.
Copy link to clipboard
Copied
anyone help to Make a Frame all Layer in PS Scriptx with retain effects of layers like shadow border etc.
By @Prathamesh301522420vk7
I don't know what you are looking for. Please illustrate your request with before/after screenshots with the layers and other applicable panels visible and or step-by-step instructions.
EDIT: You have made a duplicate request here:
Copy link to clipboard
Copied
https://www.youtube.com/watch?v=GmpL2iIJMPU please check video.
layer to frame script
1. selected layers convrted to frames with effects remain
2. work on all type object mask or shapes
i know it needs proper script and only exprt like you can give me script
Find more inspiration, events, and resources on the new Adobe Community
Explore Now