r-bin
People's Champ
r-bin
People's Champ
Activity
May 19, 2024
02:03 PM
What is theText found in this line, for example? var saveFilePSD = File(theText + "/" + val + " " + Dsize2 + ".psd");
... View more
May 17, 2024
11:07 AM
1 Upvote
I think that this is impossible. You can try changing the finished script so that it does not use fore(back)groundColor.
... View more
May 17, 2024
10:47 AM
3 Upvotes
... In Save for Web, you need to include All Metadata. This is not a scriptable option .... By @Lumigraphics You can check with ScriptingListener. For example: no metadata d1.putEnumerated(charIDToTypeID("SWmd"), charIDToTypeID("STmd"), charIDToTypeID("MDNn")); all metadata d1.putEnumerated(charIDToTypeID("SWmd"), charIDToTypeID("STmd"), charIDToTypeID("MDAl"));
... View more
May 16, 2024
12:57 PM
2 Upvotes
It's not very clear what exactly you want to delete. This script removes all "Make" commands from the ActionSet "Default Actions->Frame Channel - 50 pixel". Modify it to suit yourself. for (var i = 1; i < 100000; i++)
{
var r = new ActionReference();
r.putIndex(stringIDToTypeID("command"), i);
r.putName(stringIDToTypeID("action"), "Frame Channel - 50 pixel");
r.putName(stringIDToTypeID("actionSet"), "Default Actions");
var nm = executeActionGet(r).getString(stringIDToTypeID("name"));
// alert(nm);
if (nm == "Make")
{
var d = new ActionDescriptor();
var r = new ActionReference();
r.putIndex(stringIDToTypeID("command"), i);
r.putName(stringIDToTypeID("action"), "Frame Channel - 50 pixel");
r.putName(stringIDToTypeID("actionSet"), "Default Actions");
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
--i;
}
}
... View more
May 13, 2024
12:21 PM
1 Upvote
Can the flip state be calculated from the values of xy and yy? Or there are other ways By @javaer You can try it this way var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("textKey"));
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var tkey = executeActionGet(r).getObjectValue(stringIDToTypeID("textKey"));
var xx = 1;
var xy = 0;
var yx = 0;
var yy = 1;
var tx = 0;
var ty = 0;
if (tkey.hasKey(stringIDToTypeID("transform")))
{
xx = tkey.getObjectValue(stringIDToTypeID("transform")).getDouble(stringIDToTypeID("xx"));
xy = tkey.getObjectValue(stringIDToTypeID("transform")).getDouble(stringIDToTypeID("xy"));
yx = tkey.getObjectValue(stringIDToTypeID("transform")).getDouble(stringIDToTypeID("yx"));
yy = tkey.getObjectValue(stringIDToTypeID("transform")).getDouble(stringIDToTypeID("yy"));
tx = tkey.getObjectValue(stringIDToTypeID("transform")).getDouble(stringIDToTypeID("tx"));
ty = tkey.getObjectValue(stringIDToTypeID("transform")).getDouble(stringIDToTypeID("ty"));
}
var W = xx/Math.cos(Math.atan2(xy,xx))*100;
var H = (xx*yy-xy*yx)/(xx/Math.cos(Math.atan2(xy,xx)))*100;
var A = Math.atan2(xy,xx)*180.0/Math.PI;
var S = (Math.atan2(yx,yy)+Math.atan2(xy,xx))*180.0/Math.PI;
if (S < 0) S += 360;
if (S > 180) S -= 180;
if (S > 90) S -= 180;
var fliped_H = xx<0;
var fliped_V = yy<0;
if (fliped_H && fliped_V) fliped_H = fliped_V = false;
alert("Matrix:\n"+
xx.toFixed(2) + " " + yx.toFixed(2) + "\n" + xy.toFixed(2) + " " + yy.toFixed(2) + "\n\n" +
"W = " + W.toFixed(1) + "\nH = " + H.toFixed(1) + "\n\nA = " + A.toFixed(2) + "\nS = " + S.toFixed(1) + "\n\n" +
"fliped_H = "+fliped_H + "\nfliped_V = "+fliped_V);
... View more
May 12, 2024
01:43 PM
1 Upvote
May 12, 2024
11:46 AM
1 Upvote
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-get-text-transform-box-boundary/m-p/11142715 You are interested in the rectangle P2, or rather its boundaries l, t, r ,b from which you will get the width (r-l) and height (b-t). All values are in points units.
... View more
May 12, 2024
08:58 AM
1 Upvote
I don't think there are any flip statuses. They're just buttons. A horizontal flip simply reverses the sign of xx and yx, and a vertical flip reverses the sign of xy and yy.
... View more
May 10, 2024
06:23 PM
2 Upvotes
Your image looks exactly like what I have imagined. I will try it. I also found a Threshold mode of Subtract which may do the same. Do you know if Subtract is equivalent to Invert plus Darken? By @Gerald Reisz Your method is much more convenient than mine. ) No, Darken and Subtract modes are different things. In Darken mode, the result will be the darkest (per channel) color of the pixel from the current layer and everything under it. The Subtract mode is the subtraction of pixel values (in each channel). Since in your case the original treshold layer gives only white or black, then subtracting black (this is zero) does not change anything in the resulting pixels, and subtracting white (i.e. subtracting 255) just resets everything to zero (and even makes it negative, as it were, but in reality there is no less than zero)
... View more
May 10, 2024
02:56 PM
2 Upvotes
The Threshold slider seems to be in the right area except it is doing the opposite of what I want to happen. By @Gerald Reisz I don't know how this will help you, but you can do this. Make a copy of the layer and convert it to a smart object. Apply Image->Adjustment->Threshold 250 to the layer. Apply Image->Adjustment->Invert. Set the layer's blending mode to Darken. If everything is ok, flatten the layers or change the Threshold value by double clicking.
... View more
May 08, 2024
04:06 PM
2 Upvotes
Where you found it is the intersectActivePixels() function. Replace cID("Intr") with cID("Add ").
... View more
May 04, 2024
11:41 AM
1 Upvote
while (app.activeDocument.layerSets.length) {
var vis = app.activeDocument.layerSets[0].visible;
activeDocument.activeLayer = app.activeDocument.layerSets[0];
executeAction(stringIDToTypeID("newPlacedLayer"), new ActionDescriptor(), DialogModes.NO);
activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);
activeDocument.activeLayer.visible = vis;
}
... View more
May 04, 2024
05:04 AM
1 Upvote
Sorry, it’s reported on line 53. Here are lines 52 and 53 for context from the previous code posted: var desc1 = app.getCustomOptions('7a301ec0-afde-11e1-afa6-0800200c9a66');
var layerGuides = eval(desc1.getString(0)); By @Stephen Marsh Could you use a key value other than 0 when using the putString and getString function? It seems that the getCustomOptions function still returns the found descriptor and does not generate an error. Many built-in scripts use the putCustomOptions and getCustomOptions functions. If the reason is their incorrect operation, then they may also stop working correctly. These include Fit Image.jsx, Export Layers To Files.jsx and many others. If getCustomOptions does not work in these scripts, then this is an obvious bug that needs to be fixed. ADD. Also try using putCustomOptions without "true" as the third argument, i.e. use only the first two - name and descriptor.
... View more
May 03, 2024
11:25 AM
Putting an alert into the try/catch for getting the session variable results in an error "The requested property does not exist"... By @Stephen Marsh What exact code (line) causes this error?
... View more
May 01, 2024
02:58 PM
Do you have third-party plugins installed? Plugins are also in the folder ...\Required\Plug-ins
... View more
May 01, 2024
02:40 PM
2 Upvotes
Try this #target photoshop
app.bringToFront();
var doc = app.activeDocument;
var selectedLayers = getSelectedLayersIndex(doc);
if (selectedLayers.length == 2) {
try {
for (var i = 0; selectedLayers.length > i; i++) {
var sLayers = new Array();
for (var i = 0, l = selectedLayers.length; i < l; i++) {
selectLayerByIndex(selectedLayers[i], false);
if (app.activeDocument.activeLayer.typename == "LayerSet") {
executeAction(stringIDToTypeID("newPlacedLayer"), undefined, DialogModes.NO);
var xleft = activeDocument.activeLayer.bounds[0]
var ytop = activeDocument.activeLayer.bounds[1];
var ybot = activeDocument.activeLayer.bounds[3];
var width = activeDocument.activeLayer.bounds[2] - activeDocument.activeLayer.bounds[0];
var height = activeDocument.activeLayer.bounds[3] - activeDocument.activeLayer.bounds[1];
var xcenter = activeDocument.activeLayer.bounds[0] + width / 2
var ycenter = activeDocument.activeLayer.bounds[1] + height / 2
var xright = activeDocument.activeLayer.bounds[2]
app.activeDocument.activeHistoryState = app.activeDocument.historyStates[app.activeDocument.historyStates.length - 2];
selectLayerByIndex(selectedLayers[i], false);
} else {
var xpos = activeDocument.activeLayer.bounds[0];
var ytop = activeDocument.activeLayer.bounds[1];
var ybot = activeDocument.activeLayer.bounds[3];
var width = activeDocument.activeLayer.bounds[2] - activeDocument.activeLayer.bounds[0];
var height = activeDocument.activeLayer.bounds[3] - activeDocument.activeLayer.bounds[1];
var xcenter = activeDocument.activeLayer.bounds[0] + width / 2
var ycenter = activeDocument.activeLayer.bounds[1] + height / 2
var xleft = activeDocument.activeLayer.bounds[0]
var xright = activeDocument.activeLayer.bounds[2]
}
sLayers.push([activeDocument.activeLayer, xleft, ytop, width, height, xcenter, ycenter, xright, ybot]);
}
var oneWidth = sLayers[0][3]
var oneHeight = sLayers[0][4]
var oneXcenter = sLayers[0][5]
var oneYcenter = sLayers[0][6]
var twoWidth = sLayers[1][3]
var twoHeight = sLayers[1][4]
var twoXcenter = sLayers[1][5]
var twoYcenter = sLayers[1][6]
doc.activeLayer = sLayers[0][0]
Xdelta = twoXcenter - oneXcenter;
Ydelta = twoYcenter - oneYcenter;
transform(Xdelta, Ydelta, 100, 100);
doc.activeLayer = sLayers[1][0]
Xdelta = oneXcenter - twoXcenter;
Ydelta = oneYcenter - twoYcenter;
transform(Xdelta, Ydelta, 100, 100);
///////////////////////////////////////////////////////
for (var i = 0, l = selectedLayers.length; i < l; i++) {
selectLayerByIndex(selectedLayers[i], true);
}
}
} catch (e) {
alert(e + ': on line ' + e.line, 'Script Error', true);
}
}
function transform(DeltaX, DeltaY, WidthPercent, HeightPercent) {
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
descriptor.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));
descriptor2.putUnitDouble(stringIDToTypeID("horizontal"), stringIDToTypeID("pixelsUnit"), DeltaX);
descriptor2.putUnitDouble(stringIDToTypeID("vertical"), stringIDToTypeID("pixelsUnit"), DeltaY);
descriptor.putObject(stringIDToTypeID("offset"), stringIDToTypeID("offset"), descriptor2);
descriptor.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), WidthPercent);
descriptor.putUnitDouble(stringIDToTypeID("height"), stringIDToTypeID("percentUnit"), HeightPercent);
try {
executeAction(stringIDToTypeID("transform"), descriptor, DialogModes.NO);
} catch (e) {
alert(e + ': on line ' + e.line, 'Script Error', true);
}
}
function getSelectedLayersIndex(doc) {
var selectedLayers = [];
var ref = new ActionReference();
ref.putEnumerated(cTID('Dcmn'), cTID('Ordn'), cTID('Trgt'));
var desc = executeActionGet(ref);
if (desc.hasKey(sTID('targetLayers'))) {
desc = desc.getList(sTID('targetLayers'));
var c = desc.count;
for (var i = 0; i < c; i++) {
try {
doc.backgroundLayer;
selectedLayers.push(desc.getReference(i).getIndex());
} catch (e) {
selectedLayers.push(desc.getReference(i).getIndex() + 1);
}
}
} else {
var ref = new ActionReference();
ref.putProperty(cTID('Prpr'), cTID('ItmI'));
ref.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));
try {
doc.backgroundLayer;
selectedLayers.push(executeActionGet(ref).getInteger(cTID('ItmI')) - 1);
} catch (e) {
selectedLayers.push(executeActionGet(ref).getInteger(cTID('ItmI')));
}
}
return selectedLayers;
}
function selectLayerByIndex(index, add) {
var ref = new ActionReference();
ref.putIndex(charIDToTypeID("Lyr "), index);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID("null"), ref);
if (add) desc.putEnumerated(stringIDToTypeID("selectionModifier"), stringIDToTypeID("selectionModifierType"), stringIDToTypeID("addToSelection"));
desc.putBoolean(charIDToTypeID("MkVs"), false);
try {
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO);
} catch (e) {}
}
function cTID(s) {
return app.charIDToTypeID(s);
}
function sTID(s) {
return app.stringIDToTypeID(s);
}
... View more
May 01, 2024
02:09 PM
РАЗРАБОТЧИКИ! Этот новый синий контур выключается, а потом включается автоматически, я уже устал его переключать с помощью ctr+h. Исправьте пожалуйста этот хрень Конечно, компания с миллионным доходом не может позволить себе избежать подобных упущений. Браво! By @FreeTime Да уж. Этот хрень всем хреням хрень. ) View->Show->Layer Edges - не оно ли включено?
... View more
May 01, 2024
01:53 PM
1 Upvote
Perhaps you have a smart object layer in your PSD with your RAW file. Then it is enough to export the contents for the smart object.
... View more
May 01, 2024
01:28 PM
1 Upvote
You can add an effect to existing ones using the set_fx() function. You need to create a descriptor with the parameters of the desired effect and call the function. The example shows how you can add a stroke effect without worrying about what effects were (or were not) applied to the layer before. // cteate stroke fx descriptor
var d = new ActionDescriptor();
d.putBoolean(stringIDToTypeID("enabled"), true);
d.putEnumerated(stringIDToTypeID("style"), stringIDToTypeID("frameStyle"), stringIDToTypeID("outsetFrame"));
d.putEnumerated(stringIDToTypeID("paintType"), stringIDToTypeID("frameFill"), stringIDToTypeID("solidColor"));
d.putEnumerated(stringIDToTypeID("mode"), stringIDToTypeID("blendMode"), stringIDToTypeID("normal"));
d.putUnitDouble(stringIDToTypeID("opacity"), stringIDToTypeID("percentUnit"), 100);
d.putUnitDouble(stringIDToTypeID("size"), stringIDToTypeID("pixelsUnit"), 18);
var d1 = new ActionDescriptor();
d1.putDouble(stringIDToTypeID("red"), 255);
d1.putDouble(stringIDToTypeID("green"), 0);
d1.putDouble(stringIDToTypeID("blue"), 0);
d.putObject(stringIDToTypeID("color"), stringIDToTypeID("RGBColor"), d1);
set_fx("frameFX", d);
function set_fx(fx_type, fx_desc)
{
try {
var fx = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerEffects"));
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var d = executeActionGet(r);
if (d.hasKey(stringIDToTypeID("layerEffects"))) fx = d.getObjectValue(stringIDToTypeID("layerEffects"));
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerEffects"));
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
d.putReference(stringIDToTypeID("null"), r);
fx.putObject(stringIDToTypeID(fx_type), stringIDToTypeID(fx_type), fx_desc);
d.putObject(stringIDToTypeID("to"), stringIDToTypeID("layerEffects"), fx);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
}
catch (e) { alert(e.line+"\n\n"+e); }
}
... View more
Apr 29, 2024
04:58 PM
1 Upvote
May be useful https://helpx.adobe.com/photoshop/using/creating-data-driven-graphics.html https://helpx.adobe.com/photoshop/using/create-smart-objects.html
... View more
Apr 28, 2024
09:08 AM
2 Upvotes
It looks like I found the cause of this "bug". Guides created through DOM and AM code are no different. This is confirmed by a bit-by-bit comparison of psd files with such guides. When using DOM guides.add(), some internal information is not updated and it appears that the SnapTo function does not see or know about the new guides. If you save the file and then Revert or re-open it, then SnapTo starts working as it should for such guides. This is definitely a bug.
... View more
Apr 28, 2024
04:58 AM
1 Upvote
I don't use Frames, but as far as I know, a Frame physically consists of at least two "layers". This is a folder and a layer within that folder. The result may depend on whether the "folder" or layer within it is currently active.
... View more
Apr 27, 2024
04:38 PM
@Stephen Marsh wrote: What happens when you explicitly set the ruler units via the DOM (which is always a good practice)? That's not the point. P.S. A good practice would be to use UnitValue(800, "px") instead of just 800. But that doesn't help in this case.
... View more
Apr 27, 2024
04:29 PM
2 Upvotes
Thank you @r-bin Should I conclude that ActionDescriptor is the way to go when possible? By @Deleted User You didn’t specify whether, when creating guides using this code, everything is fine with snapping the selection to the guides? Classic DOM methods, such as guides.add(), are based (according to unverified rumors) on AM code and the use of ActionDescriptor and executeAction. So if it is more convenient in the code, then it is not forbidden to use it. However, as you yourself noticed in your case, there may be some oddities and bugs when using only DOM methods.
... View more
Apr 27, 2024
01:25 PM
1 Upvote
If you only need to cancel the transformation, then you can do this var layer0 = app.activeDocument.activeLayer;
var r = new ActionReference();
r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("textKey"));
r.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
var textKey = executeActionGet(r).getObjectValue(stringIDToTypeID("textKey"));
textKey.erase(stringIDToTypeID("transform"));
var r = new ActionReference();
r.putClass(stringIDToTypeID( "textLayer"));
var d = new ActionDescriptor();
d.putReference(stringIDToTypeID("null"), r);
d.putObject(stringIDToTypeID("using"), stringIDToTypeID("textLayer"), textKey);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
layer0.remove();
... View more
Apr 27, 2024
01:04 PM
Try using "Insert Conditional..."
... View more
Apr 27, 2024
10:59 AM
2 Upvotes
How did you run the script while recording the Action? It looks like it's through some kind of extension.
... View more
Apr 27, 2024
10:56 AM
2 Upvotes
Yes, a really interesting bug. Try using this code to add guides. var d = new ActionDescriptor();
var d1 = new ActionDescriptor();
d1.putUnitDouble(stringIDToTypeID("position"), stringIDToTypeID("pixelsUnit"), 600);
d1.putEnumerated(stringIDToTypeID("orientation"), stringIDToTypeID("orientation"), stringIDToTypeID("horizontal"));
d.putObject(stringIDToTypeID("new"), stringIDToTypeID("guide"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
var d = new ActionDescriptor();
var d1 = new ActionDescriptor();
d1.putUnitDouble(stringIDToTypeID("position"), stringIDToTypeID("pixelsUnit"), 800);
d1.putEnumerated(stringIDToTypeID("orientation"), stringIDToTypeID("orientation"), stringIDToTypeID("horizontal"));
d.putObject(stringIDToTypeID("new"), stringIDToTypeID("guide"), d1);
executeAction(stringIDToTypeID("make"), d, DialogModes.NO); The snap seems to be working as it should.
... View more
Apr 25, 2024
11:13 AM
var layername = docRef.activeLayer.name;
... View more
Apr 21, 2024
01:43 PM
I'm not familiar with XML and don't really want to understand its syntax. But look at the picture What was in the original code at this point?
... View more