Skip to content

Instantly share code, notes, and snippets.

@joonaspaakko
Created March 29, 2016 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joonaspaakko/0d04dfcf434d5d9db75b to your computer and use it in GitHub Desktop.
Save joonaspaakko/0d04dfcf434d5d9db75b to your computer and use it in GitHub Desktop.
Saves a file in Photoshop as jpg. File path is based on current document and filename is based on current layer.
var doc = app.activeDocument;
var fileName = doc.activeLayer.name;
var outputLocation= File( doc.path + "/" + fileName );
save( outputLocation );
function save( outputLocation ) {
var saveOptions = new ExportOptionsSaveForWeb;
saveOptions.format = SaveDocumentType.JPEG;
saveOptions.optimized = true;
saveOptions.interlaced = true;
saveOptions.quality = 100;
doc.exportDocument( new File( outputLocation ), ExportType.SAVEFORWEB, saveOptions );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment