[FIXED] JSX/Photoshop: app.activeivedocument.Saveas () Rückgabefehler

Ausgabe

Ich versuche, das activeDocumentals .psd zu speichern, aber es gibt diesen Fehler zurück

FEHLER: Allgemeiner Photoshop-Fehler aufgetreten. Diese Funktion ist in dieser Version von Photoshop möglicherweise nicht verfügbar.

mein Skript:

#target photoshop

var fileRef = new File(app.path.toString() + "/Samples/template.psd");
var docRef = open(fileRef);

//target text layer
var layerRef = app.activeDocument.layers.getByName("Text");

//user input
var newText = prompt("Editing " + layerRef.name, "enter new text: ");

//change contents
layerRef.textItem.contents = newText;

//save
var savePath = "/Samples/" + newText + ".psd";
var saveFile = new File(savePath);
var saveOptions = new PhotoshopSaveOptions();
saveOptions.alphaChannels = false;
saveOptions.annotations = false;
saveOptions.embedColorProfile = true;
saveOptions.layers = true;
saveOptions.spotColors = false;

app.activeDocument.saveAs(saveFile, saveOptions, true, Extension.LOWERCASE);
app.activeDocument.close();

Was ich tun möchte, ist im Grunde, eine Vorlagendatei immer wieder zu duplizieren, nur den Inhalt einer Textebene zu ersetzen und ihn dann unter der Zeichenfolge zu speichern, die ich in der Textebene ersetze.

alle Tipps oder Hilfe wird sehr geschätzt.

Lösung

Beschlossen

Ich habe mein Problem durch eine Umgehung behoben. Ich habe sowohl das Skript als auch die Vorlagendatei in das Photoshop-Verzeichnis verschoben und app.path.toString()zur saveFileAusgabevariable hinzugefügt. Es scheint also, dass der Pfad vor dem Speichern in eine Zeichenfolge konvertiert werden musste.

Ich bin mir noch nicht sicher, wie ich außerhalb des Photoshop-Verzeichnisses arbeiten soll , aber für mich funktioniert das, also bin ich glücklich. Es ist ziemlich grob, aber ich bin offen für Vorschläge. Wenn also jemand ein ähnliches Problem hat, kann er dies als Referenz verwenden.

#target photoshop

var loop = true;
var filePath = "/Samples/template.psd";

while(loop) {
  openTemplate(filePath);
  var layerRef = app.activeDocument.layers.getByName("Text"); //target text layer
  var newText = prompt("Editing " + layerRef.name, "enter new text: "); //user input

  if(newText == "stop") { //stop loop by entering 'stop'
    loop = false;
  }

  layerRef.textItem.contents = newText;
  var savePath = app.path.toString() + "/Samples/" + newText + ".psd";
  var saveFile = new File(savePath);
  savePSD(saveFile);
  app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}

function openTemplate(filePath) { //open template.psd
  var fileRef = new File(app.path.toString() + filePath);
  var docRef = open(fileRef);
}

function savePSD(saveFile) { //saveas newText.psd
  var saveOptions = new PhotoshopSaveOptions();
  saveOptions.alphaChannels = false;
  saveOptions.annotations = false;
  saveOptions.embedColorProfile = true;
  saveOptions.layers = true;
  saveOptions.spotColors = false;
  app.activeDocument.saveAs(saveFile, saveOptions, true, Extension.LOWERCASE);
}


Beantwortet von –
Dylan


Antwort geprüft von –
Marie Seifert (FixError Admin)

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like