使用 Actionscript 在 Photoshop 複製影像尺寸

  • 0


手邊需要一邊裁切圖片,另外一頭要複製影像尺寸,因此寫了這個 ActionScript

app.preferences.rulerUnits  = Units.CM;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
var white = new SolidColor(); 
numW=Math.ceil(w*10)/10;
numH=Math.ceil(h*10)/10;
var message=numW+"*"+numH+"公分";

 var folderForTempFiles = Folder.temp.fsName;
 var text=message;

   // create a new textfile and put the text into it

   var clipTxtFile =new File(folderForTempFiles + "/ClipBoard.txt"); 
   clipTxtFile.open('w'); 
   clipTxtFile.write(text); 
   clipTxtFile.close();

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