Search code examples
javascriptphotoshopextendscript

How I can save file with script Photoshop?


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)


Solution

  • You missed off the extension :D

     saveFile = new File( "c:\\temp\\" + thistimestamp) + ".jpg");