问题描述
我有非常大的1位图像,我需要在Photoshop中编写文本数组。我可以通过将图像转换为灰度,然后为每个文本块创建一个新图层,在javascript中执行此操作,但我希望能够将文本直接写入1位位图以节省时间。有没有办法在javascript中执行此操作?
I have very large size 1-bit images that I need to write arrays of text to in Photoshop. I can do this in javascript by converting the images to grayscale and then creating a new layer for each block of text, but I would like to be able to write text directly onto the 1-bit bitmap to save time. Is there a way to do this in javascript?
推荐答案
您可以使用脚本创建文本。您需要使用灰度(或RGB)才能执行此操作。
这是一个基本的文本功能。您必须在创建文本后对其进行定位,因为在创建之前无法获得文本的大小。希望这会有所帮助。
You can create text with scripting. You will need to be in grayscale (or RGB) to do so.Here's a basic text function. You will have to position the text after it is created as there is no way of getting it's size before it's creation. Hope this helps.
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
}
这篇关于Photoshop脚本在Photoshop中创建位图图像中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!