2013-10-09 67 views
1

我有需要在Photoshop中编写文本数组的大尺寸1位图像。我可以通过将图像转换为灰度,然后为每个文本块创建一个新图层来实现这一点,但我希望能够将文本直接写入1位位图以节省时间。有没有办法在JavaScript中做到这一点?Photoshop脚本在Photoshop中的位图图像中创建文本

回答

2

您可以使用脚本创建文本。您需要使用灰度(或RGB)才能这样做。 这是一个基本的文字功能。在创建文本之后,您必须定位文本,因为在创建文本之前无法获取它的大小。希望这可以帮助。

createText("Arial-BoldMT", 48, 0,128,0, "Hello World", 100, 50) 
activeDocument.activeLayer.name = "Text"; 
activeDocument.activeLayer.textItem.justification = Justification.CENTER 

function createText(fface, size, colR, colG, colB, content, tX, tY) 
{ 
    // Add a new layer in the new document 
    var artLayerRef = app.activeDocument.artLayers.add() 

    // Specify that the layer is a text layer 
    artLayerRef.kind = LayerKind.TEXT 

    //This section defines the color of the hello world text 
    textColor = new SolidColor(); 
    textColor.rgb.red = colR; 
    textColor.rgb.green = colG; 
    textColor.rgb.blue = colB; 

    //Get a reference to the text item so that we can add the text and format it a bit 
    textItemRef = artLayerRef.textItem 
    textItemRef.font = fface; 
    textItemRef.contents = content; 
    textItemRef.color = textColor; 
    textItemRef.size = size 
    textItemRef.position = new Array(tX, tY) //pixels from the left, pixels from the top 
}