My psd file has a text layer. I have a stroke effect on the text. I want to get the font size of the text layer, the stroke color and the stroke width. As shown in my screenshot: 1715155305406.png (14.7 KB)
I tried many ways and looked at the api but couldn’t find a suitable way to get the information I needed to use aspose-psd for Java.
Font font = textLayer.getFont();
int size = font.getSize();
The font size returned by the above method is not the same as the one I showed in photoshop and will be the same for multiple text layers of the same psd file.
And how to get the text stroke method, I have not found, please help!
Thank you very much! The method you provided works, but when the text is not horizontal, it can’t be simply computed using matrix[0] * baseFontSize.
Are there more detailed instructions for using the transformation matrix data? I don’t really understand this part.
Also, how to get the stroke information of the text layer, such as whether there is a stroke, the width of the stroke, and the color of the stroke. thank you.
To get the stroke data please use the following code:
ILayerEffect[] effects = im.getLayers()[index].getBlendingOptions().getEffects();
for (int i = 0; i < effects.length; i++) {
if (effects[i] instanceof StrokeEffect) {
StrokeEffect effect = (StrokeEffect)effects[i];
// Here is size of Stroke
int size = effect.getSize();
}
}
I’ve taken your code and adapted it to fit the context of my code, but all the text layers are getting an ILayerEffect array of 0. I tried two versions of the sdk, one is 23.4, the other is the latest 24.4, and I got both empty arrays of ILayerEffect. I’m sure I have two text layers with stroke enabled.
And help me see what the problem is. Please see my screenshot. Thanks! 1715223243745.png (57.5 KB) 1715223243755.png (63.8 KB)
@Liujinye please try to use the following code for file opening:
PsdLoadOptions psdLoadOptions = new PsdLoadOptions();
psdLoadOptions.setLoadEffectsResource(true);
psdLoadOptions.setUseDiskForLoadEffectsResource(true);
PsdImage image = (PsdImage)Image.load("test.psd", psdLoadOptions);
// Here is manipulation with effects.