Created
June 4, 2012 09:38
-
-
Save kuyseng/2867476 to your computer and use it in GitHub Desktop.
javascript: photoshop save for web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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