• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problem with saveAs in javascript

New Here ,
May 26, 2008 May 26, 2008

Copy link to clipboard

Copied

Hello
I'm trying to save jpgs one by one using a for loop. This is what I have to save:

var saveFile = new File(outputFolder + "/large/" + baseNameVar + "_" + startNumVar + "_large.jpg");
var jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.quality = 12;
activeDocument.saveAs( saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

I get this error:
General Photoshop error occurred. This functionality may not be available in this version of Photoshop.

Any ideas?
I'm using Photoshop CS3 on a Mac.
TOPICS
Actions and scripting

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
May 28, 2008 May 28, 2008

Copy link to clipboard

Copied

I think it may be this line:

activeDocument.saveAs( saveFile, jpgSaveOptions, true, Extension.LOWERCASE);

put a folder destination instead of the file location as the first parameter...

this is how I do:

//choose folder
var myFolder = Folder.selectDialog ();

//create new folder within chosen folder
var newFolder = new Folder(myFolder + "/newSaveFolder");
var exportFolder = new Folder(myFolder + "/newExportFolder");

newFolder.create();
exportFolder.create();

//create document
var myDoc = app.documents.add(10,10, 72, "exportOptions", undefined);

//save document in folder
myDoc.saveAs(newFolder)

similar but not exactly what u may want to do, still. Good luck.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 02, 2008 Jun 02, 2008

Copy link to clipboard

Copied

Inspect the file that you are trying to save. It might contain characters that are not supported by the OS.

Something like LogInfo(saveFile.fsName); to see exactly what you are trying to save before you save it.

You will need to write LogInfo of course.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 23, 2008 Jul 23, 2008

Copy link to clipboard

Copied

LATEST
I had a similar problem when running a javascript snippet within AppleScript. I was trying to batch-generate compressed TIFFs from PSDs, but the compression request seemed to be ignored in pure AppleScript.

I cobbled together the javascript string as follows -
('destFile' is predetermined)

set jScript to " var saveOptions = new TiffSaveOptions();
saveOptions.transparency = true;
saveOptions.layers = false;
saveOptions.imageCompression = TIFFEncoding.TIFFLZW;
saveOptions.layerCompression = LayerCompression.ZIP;
saveOptions.embedColorProfile = true;

var nps = " & quoted form of destFile & ";
var np = new File(nps);
app.activeDocument.saveAs(np, saveOptions, false, Extension.LOWERCASE );"

By creating the file object in two steps outside of the saveAs command, it worked.

Not only that, but compression worked as it should.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines