2016-09-22 8 views
1

私は大手ファッション会社で働いています。私たちには2種類のJPGを作成する必要がある古いPLMシステムがあります。その後、当社のベンダーは特定の出力プリセットをPDFに送信する必要があります。Photoshop Script for Momentis(PLM)

私は、私が以下に投稿する必要があるほとんどのスクリプトを手に入れることができましたが、ファイル名を取得できないように思えます。保存時に古い拡張子を削除したい新しいファイル、私が試したことのすべては、そうではなかった。

また、私は、PSDがPhotoshopで現在開いているアクティブなドキュメントであることを再度元の場所に保存することを希望します。

ご指摘いただければ幸いです。

// Saves the current state of the open document, so we can revert to it later to re-save the image to the correct document format 
var savedState = app.activeDocument.activeHistoryState; 

var sourceDoc = app.activeDocument.name; 

// Saves Open Document as PDF to server location 
var idsave = charIDToTypeID("save"); 
var desc60 = new ActionDescriptor(); 
var idAs = charIDToTypeID("As "); 
    var desc61 = new ActionDescriptor(); 
    var idpdfPresetFilename = stringIDToTypeID("pdfPresetFilename"); 
    desc61.putString(idpdfPresetFilename, """GYMDESIGN"""); 
    var idpdfOutputConditionIdentifier = stringIDToTypeID("pdfOutputConditionIdentifier"); 
    desc61.putString(idpdfOutputConditionIdentifier, '""""""'); 
    var idpdfRegistryName = stringIDToTypeID("pdfRegistryName"); 
    desc61.putString(idpdfRegistryName, '""""""'); 
var idPhtP = charIDToTypeID("PhtP"); 
desc60.putObject(idAs, idPhtP, desc61); 
var idIn = charIDToTypeID("In "); 
desc60.putPath(idIn, new File("/our server location/"+ sourceDoc + ".pdf")); 
var idDocI = charIDToTypeID("DocI"); 
desc60.putInteger(idDocI, 320); 
var idLwCs = charIDToTypeID("LwCs"); 
desc60.putBoolean(idLwCs, true); 
var idsaveStage = stringIDToTypeID("saveStage"); 
var idsaveStageType = stringIDToTypeID("saveStageType"); 
var idsaveBegin = stringIDToTypeID("saveBegin"); 
desc60.putEnumerated(idsaveStage, idsaveStageType, idsaveBegin); 
executeAction(idsave, desc60, DialogModes.NO); 

// Saves Open Document as JPG to server location 
var idsave = charIDToTypeID("save"); 
var desc68 = new ActionDescriptor(); 
var idAs = charIDToTypeID("As "); 
    var desc69 = new ActionDescriptor(); 
    var idEQlt = charIDToTypeID("EQlt"); 
    desc69.putInteger(idEQlt, 12); 
    var idMttC = charIDToTypeID("MttC"); 
    var idMttC = charIDToTypeID("MttC"); 
    var idNone = charIDToTypeID("None"); 
    desc69.putEnumerated(idMttC, idMttC, idNone); 
var idJPEG = charIDToTypeID("JPEG"); 
desc68.putObject(idAs, idJPEG, desc69); 
var idIn = charIDToTypeID("In "); 
desc68.putPath(idIn, new File("/our server location/" + sourceDoc + ".jpg")); 
var idDocI = charIDToTypeID("DocI"); 
desc68.putInteger(idDocI, 320); 
var idLwCs = charIDToTypeID("LwCs"); 
desc68.putBoolean(idLwCs, true); 
var idsaveStage = stringIDToTypeID("saveStage"); 
var idsaveStageType = stringIDToTypeID("saveStageType"); 
var idsaveBegin = stringIDToTypeID("saveBegin"); 
desc68.putEnumerated(idsaveStage, idsaveStageType, idsaveBegin); 
executeAction(idsave, desc68, DialogModes.NO); 

// Scales Open Document to 25% resolution 
var idImgS = charIDToTypeID("ImgS"); 
var desc76 = new ActionDescriptor(); 
var idRslt = charIDToTypeID("Rslt"); 
var idRsl = charIDToTypeID("#Rsl"); 
desc76.putUnitDouble(idRslt, idRsl, 25.000000); 
var idscaleStyles = stringIDToTypeID("scaleStyles"); 
desc76.putBoolean(idscaleStyles, true); 
var idCnsP = charIDToTypeID("CnsP"); 
desc76.putBoolean(idCnsP, true); 
var idIntr = charIDToTypeID("Intr"); 
var idIntp = charIDToTypeID("Intp"); 
var idautomaticInterpolation = stringIDToTypeID("automaticInterpolation"); 
desc76.putEnumerated(idIntr, idIntp, idautomaticInterpolation); 
executeAction(idImgS, desc76, DialogModes.NO); 

// Saves scaled Open Document to thumbnail size, and to server location 
var idsave = charIDToTypeID("save"); 
var desc81 = new ActionDescriptor(); 
var idAs = charIDToTypeID("As "); 
    var desc82 = new ActionDescriptor(); 
    var idEQlt = charIDToTypeID("EQlt"); 
    desc82.putInteger(idEQlt, 5); 
    var idMttC = charIDToTypeID("MttC"); 
    var idMttC = charIDToTypeID("MttC"); 
    var idNone = charIDToTypeID("None"); 
    desc82.putEnumerated(idMttC, idMttC, idNone); 
var idJPEG = charIDToTypeID("JPEG"); 
desc81.putObject(idAs, idJPEG, desc82); 
var idIn = charIDToTypeID("In "); 
desc81.putPath(idIn, new File("/our server location/" + sourceDoc + "_thumb" + ".jpg")); 
var idDocI = charIDToTypeID("DocI"); 
desc81.putInteger(idDocI, 320); 
var idLwCs = charIDToTypeID("LwCs"); 
desc81.putBoolean(idLwCs, true); 
var idsaveStage = stringIDToTypeID("saveStage"); 
var idsaveStageType = stringIDToTypeID("saveStageType"); 
var idsaveBegin = stringIDToTypeID("saveBegin"); 
desc81.putEnumerated(idsaveStage, idsaveStageType, idsaveBegin); 
executeAction(idsave, desc81, DialogModes.NO); 

//Restore save state from earlier in the document 
app.activeDocument.activeHistoryState = savedState; 

// Resaves as PSD file to original location 
var idsave = charIDToTypeID("save"); 
var desc88 = new ActionDescriptor(); 
var idAs = charIDToTypeID("As "); 
    var desc89 = new ActionDescriptor(); 
var idPhtthree = charIDToTypeID("Pht3"); 
desc88.putObject(idAs, idPhtthree, desc89); 
var idIn = charIDToTypeID("In "); 
desc88.putPath(idIn, new File("original location" + sourceDoc + ".psd")); 
var idDocI = charIDToTypeID("DocI"); 
desc88.putInteger(idDocI, 320); 
var idLwCs = charIDToTypeID("LwCs"); 
desc88.putBoolean(idLwCs, true); 
var idsaveStage = stringIDToTypeID("saveStage"); 
var idsaveStageType = stringIDToTypeID("saveStageType"); 
var idsaveBegin = stringIDToTypeID("saveBegin"); 
desc88.putEnumerated(idsaveStage, idsaveStageType, idsaveBegin); 
executeAction(idsave, desc88, DialogModes.NO); 

答えて

0

ようこそStackOverflow。

コードを見るだけで、履歴の状態や保存を使用した後に拡張機能が追加されていると思います。避けるために、保存する前に拡張子を削除してください。

sourcedocにこの機能を使用してみてください

function removeImageExtension (s) 
{ 
    return s.substring(0, s.lastIndexOf(".")); 
} 


sourceDoc = "/our server location/" + sourceDoc + ".jpg"; 
sourceDoc = removeImageExtension(sourceDoc); 
// /our server location/sourceDoc 
sourceDoc ="/our server location/" + sourceDoc + "_thumb" + ".jpg" 
// /our server location/sourceDoc_thumb.jpg 
関連する問題