Copy link to clipboard
Copied
Quick question
How convert PX to CM ?
var doc = activeDocument;
var artLayer = activeDocument.activeLayer;
var textItem = artLayer.textItem;
textItem.kind = TextType.PARAGRAPHTEXT;
var textWidth = textItem.width.as("px");
var textHeight = textItem.height.as("px");
alert(textWidth+"_"+textHeight);
textItem.width.as("cm"); ----> It does not show the correct value and the value is different depending on the resolution.
;
Copy link to clipboard
Copied
I believe you need to set the units for everything to what ever you want to use:
app.preferences.rulerUnits = Units.PIXELS;
Copy link to clipboard
Copied
I found a solution
var LB = activeDocument.activeLayer.bounds;
var width = LB[2].as("cm") - LB[0].as("cm");
alert(width);
Copy link to clipboard
Copied
I found a solution
Copy link to clipboard
Copied
My point was that I found a way to solve my problem differently.
I wanted to know the width of the text in centimeters and now I know.
If I mislead you, I apologize;) Of course, textItem.width is still useless.