I want to write a script that would substitute different text from a text file into my shalon and save the image in jpeg format.
An error occurs: "This function may not be available in this version of Photoshop" on this line:
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
My code:
while(!myFile.eof)
{
line = myFile.readln();
createText(line);
var thistimestamp = Math.round(new Date().getTime() / 1000);
saveFile = new File( "/c/Users/marki/Desktop/Temp001/" +thistimestamp)
saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 9;
app.activeDocument.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);
}
I use Adobe Photoshop: 2017.0.0 20161012.r.53 2016/10/12:23:00:00 CL 1094006 ( x64)
2
Answers
Taking that your script
createFile()
is well defined and working, you are missing document creation commandapp.documents.add()
before you start issuing commands. You are also missing file open procedures. When added, the code works fine:This code is tested with version 20.0.2 20181219.r.30 2018/12/19: 1202136 x64
The text file content is:
And the result in Photoshop is:
Of course, all three documents are saved as jpegs in c:temp.
In case you don’t have a working
createText
function, you can find an example in this article. The function in this example is taken from that article.You missed off the extension 😀