2017-06-19 3 views
0

元のPSDを修正して元のものを削除しようとしていますが、新しいjpgとして保存したいだけです。私のコードは次の行で正常に動作している:Photoshop CC 2017 ExtendScript Tool Kitの.remove()は関数エラーではありません

activeDocument.close(SaveOptions.DONOTSAVECHANGES); \t // Close Original Image

しかし、私はこの行と行の上に置き換えたとき:

psd.remove(); \t // I want to delete Original file

それは私にremove() is not a functionエラーを与えます。

完全なスクリプトです。私はPhotoshop JS Guide 2015を読むのに疲れているし、この問題もGoogleには答えてもらえませんでした。

var defaultRulerUnits = preferences.rulerUnits; 
 
preferences.rulerUnits = Units.PIXELS; 
 

 
if (documents.length >= 1){ 
 

 
var hres = 0; 
 
var vres = 0; 
 
var OldName = activeDocument.name.substring(0, activeDocument.name.indexOf('.')); 
 
var CurrentFolder = activeDocument.path; 
 
var psd = app.activeDocument; 
 
hres = activeDocument.width; 
 
vres = activeDocument.height; 
 

 
activeDocument.selection.selectAll(); 
 

 
if (activeDocument.layers.length >1) { 
 
\t activeDocument.selection.copy(true); 
 
} 
 

 
else{ 
 
\t if (activeDocument.layers.length =1) { 
 
\t activeDocument.selection.copy(false); 
 
\t } 
 
} 
 

 
psd.remove(); \t // I want to delete Original file 
 
     
 
var newDoc = documents.add(hres, vres, 72, OldName, NewDocumentMode.RGB, DocumentFill.WHITE); 
 

 
newDoc.paste(); 
 

 
jpgFile = new File(CurrentFolder + "/" + OldName+ ".jpg"); 
 
jpgSaveOptions = new JPEGSaveOptions(); 
 
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; 
 
jpgSaveOptions.matte = MatteType.NONE; 
 
jpgSaveOptions.quality = 12; 
 
newDoc.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE); 
 

 
}

+0

明らかに 'document'には削除メソッドがありません –

+0

どのようにして削除メソッドがありますか? Photoshop JSのガイドでは、削除方法については何も話しませんでした。私は 'psd.remove(psd);'、 'psd.remove(File);'、 'psd.remove(activeDocument);'を試しました。 – Junaid

答えて

0
srcDoc.activeLayer.remove(); 

活性層を削除します。ファイルを削除するための.remove()メソッドはありません。

関連する問題