#target photoshop
app.bringToFront();
var strtRulerUnits = app.preferences.rulerUnits;
var strtTypeUnits = app.preferences.typeUnits;
app.preferences.rulerUnits = Units.INCHES;
app.preferences.typeUnits = TypeUnits.POINTS;
var docRef = app.documents.add(7, 5, 72);
app.displayDialogs = DialogModes.NO;
var textColor = new SolidColor;
textColor.rgb.red = 255;
textColor.rgb.green = 0;
textColor.rgb.blue = 0;
var myFile = File('/c/script/text.txt');
if (myFile.exists == true){
myFile.open('r', undefined, undefined)
var line;
while(!myFile.eof)
{
line = myFile.readln();
createText(line);
}
myFile.close();
} else {
new File(myFile);
}
function createText(text){
var newTextLayer = docRef.artLayers.add();
newTextLayer.kind = LayerKind.TEXT;
newTextLayer.textItem.contents = text;
newTextLayer.textItem.position = Array(0.75, 0.75);
newTextLayer.textItem.size = 36;
newTextLayer.textItem.font = "Verdana";
newTextLayer.textItem.color = textColor;
}
app.preferences.rulerUnits = strtRulerUnits;
app.preferences.typeUnits = strtTypeUnits;
docRef = null;
textColor = null;
newTextLayer = null;
Source: https://habr.com/ru/post/41020/
All Articles