2013-09-26 40 views
1

我從來沒有在Photoshop中腳本,所以我想知道這是否可能。以下目前手動完成超過300個文件。下一次是600個文件,因此我正在考慮將其自動化。Photoshop自動對齊文字圖層與圖像

步驟:

  1. 製作圖像大小54pixels海特和500px的寬度 - 發現這是可行的。
  2. 左對齊圖像。
  3. 創建一個文本層並插入文本 - 發現這是可行的。
  4. 將文本圖層1px對齊到圖像的右側。
  5. 修剪空白空間。

將不勝感激任何幫助和指針。謝謝。

回答

1

您列出的所有內容都可以在腳本中使用。我建議你首先閱讀ExtendScript工具包程序文件目錄(例如C:\ Program Files(x86)\ Adob​​e \ Adob​​e Utilities-CS6 \ ExtendScript Toolkit CS6 \ SDK \ English)中的'Adobe Intro To Scripting'

1

This腳本會讓你開始:請注意,在你的請求中,你沒有提到原始圖像將會是什麼,將它縮小到500 x 54會以這種或那種方式拉伸。第2步,對齊左​​側的圖像,因爲你沒有提到你正在對齊這個圖像,所以省略了。我懷疑你正在處理一個大的圖像,以及如何縮小它(只要它不小於500×54)並從那裏開始工作。我也省略了第4階段,因爲我已經將文本的位置硬編碼爲右邊緣1px(並且它以Arial字體大小18垂直居中)

Anhyoo ..你應該能夠根據需要修改腳本。

// set the source document 
srcDoc = app.activeDocument; 

//set preference units 
var originalRulerPref = app.preferences.rulerUnits; 
var originalTypePref = app.preferences.typeUnits; 
app.preferences.rulerUnits = Units.POINTS; 
app.preferences.typeUnits = TypeUnits.POINTS; 

// resize image (ignoring the original aspect ratio) 
var w = 500; 
var h = 54; 
var resizeRes = 72; 
var resizeMethod = ResampleMethod.BICUBIC; 
srcDoc.resizeImage(w, h, resizeRes, resizeMethod) 

//create the text 
var textStr = "Some text"; 
createText("Arial-BoldMT", 18.0, 0,0,0, textStr, w-1, 34) 
srcDoc.activeLayer.textItem.justification = Justification.RIGHT 

//set preference units back to normal 
app.preferences.rulerUnits = originalRulerPref; 
app.preferences.typeUnits = originalTypePref; 

//trim image to transparent width 
app.activeDocument.trim(TrimType.TRANSPARENT, true, true, true, true); 

// function CREATE TEXT(typeface, size, R, G, B, text content, text X pos, text Y pos) 
// -------------------------------------------------------- 
function createText(fface, size, colR, colG, colB, content, tX, tY) 
{ 

    // Add a new layer in the new document 
    var artLayerRef = srcDoc.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 
} 
+0

夥伴,非常感謝。這絕對是一個很好的開始,我應該能夠從這裏拿走它。我會盡力將其餘的分開。 – malteseKnight