Photoshop 連續擷取圖片 - 進階版(二)

光是想題名好像就挺傷腦筋的(笑),昨天寫的語法有一個問題,就是當你開啟多個檔案的時候,很有可能會想從「非最後一個開啟」的檔案先修圖,因此就會出現檔名誤植的狀況。

為此最好的解決方法,就是將 script 分成兩段來寫,一段先負責取得名稱,然後結束;第二段則是在建立新圖檔之後,負責調整版面大小跟取回名稱。

動作設定

  1. 拷貝
  2. 指令碼(一)
  3. 製作
  4. 貼上
  5. 影像平面化
  6. 指令碼(二)


第一段腳本

// get photoshop filename
var docRef = app.activeDocument;
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
if ( fileNameNoExtension.length > 1 ) {
  fileNameNoExtension.length--;
 }
 fileNameNoExtension = fileNameNoExtension.join(".");

   // create a new textfile and put the text into it
   var folderForTempFiles = Folder.temp.fsName;
   var text = fileNameNoExtension
   var clipTxtFile =new File(folderForTempFiles + "/iMyClipBoard.txt"); 
   clipTxtFile.open('w'); 
   clipTxtFile.write(text); 
   clipTxtFile.close();

 

第二段腳本

app.preferences.rulerUnits  = Units.PIXELS;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
var white = new SolidColor(); 
white.rgb.hexValue = "FFFFFF";
app.backgroundColor = white;

numW=Math.ceil(w/80) * 75;
numH=Math.ceil(h/80) * 75;
app.activeDocument.resizeCanvas (numW, numH);



 // use the clip.exe to copy the contents of the textfile to the windows clipboard
var folderForTempFiles = Folder.temp.fsName;
var clipBatFile =new File(folderForTempFiles + "/ClipBoard.bat"); 
clipBatFile.open('w'); 
clipBatFile.writeln("type \"" + folderForTempFiles + "\\" + "iMyClipBoard.txt\" | clip"); 
clipBatFile.close(); 
clipBatFile.execute();

小泉

喜愛用文字說明自己眼中所見的一切

張貼留言

較新的 較舊

نموذج الاتصال