Skip to content

Instantly share code, notes, and snippets.

@kuyseng
Created June 4, 2012 09:38
Show Gist options
  • Save kuyseng/2867476 to your computer and use it in GitHub Desktop.
Save kuyseng/2867476 to your computer and use it in GitHub Desktop.
javascript: photoshop save for web
function saveForWebPNG(outputFolderStr, filename)
{
var opts, file;
opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.PNG;
opts.PNG8 = false;
opts.quality = 100;
if (filename.length > 27) {
file = new File(outputFolderStr + "/temp.png");
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
file.rename(filename + ".png");
}
else {
file = new File(outputFolderStr + "/" + filename + ".png");
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
}
//Photoshop on Mac limits the length of a File object's file name to 31 characters.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment