Copy link to clipboard
Copied
How to obtain the horizontal flip, vertical flip, line spacing, and letter spacing of the text layer in the psd file through script or .net
Copy link to clipboard
Copied
What I want to get most is the flipped state。The red rectangle shows the flipped text. How to get the flipped status?
Copy link to clipboard
Copied
Please provide the sample file.
And are you sure it’s flipped and not rotated 180˚?
With »A« it’s hard to tell.
Edit: Sorry, I hadn’t perused the screenshot fully.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Can the flip state be calculated from the values of xy and yy? Or there are other ways
Copy link to clipboard
Copied
Please provide the sample file.
Copy link to clipboard
Copied
Can the flip state be calculated from the values of xy and yy? Or there are other ways
By @li27112570w0z3
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);
Copy link to clipboard
Copied
To achieve these effects in Adobe Photoshop:
Horizontal Flip: Select the text layer, then go to Edit > Transform > Flip Horizontal.
Vertical Flip: Similarly, select the text layer, then go to Edit > Transform > Flip Vertical.
Line Spacing: To adjust line spacing, go to Window > Character to open the Character panel. Adjust the "Leading" option, which controls the spacing between lines of text.
Letter Spacing: With the text layer selected, go to Window > Character to open the Character panel. Adjust the "Tracking" option, which controls the spacing between individual letters.
These options allow you to manipulate text layers in various ways to achieve the desired effects.
Copy link to clipboard
Copied
I hope to get these status values through script instead of operating on the interface.
Copy link to clipboard
Copied
// based on code by michael l hale;
// 2020, use it at your own risk;
if (app.documents.length > 0) {
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID('textKey'));
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var textDesc = layerDesc.getObjectValue(stringIDToTypeID('textKey'));
try {var theTransform = textDesc.getObjectValue(stringIDToTypeID("transform"));
checkDesc2 (theTransform, true);
} catch (e) {};
};
Copy link to clipboard
Copied
Sincerely thank you all for your replies and help