Skip to content

Instantly share code, notes, and snippets.

@lapaev
Created March 11, 2015 18:38
Show Gist options
  • Select an option

  • Save lapaev/6f27a4d5fc13e077b858 to your computer and use it in GitHub Desktop.

Select an option

Save lapaev/6f27a4d5fc13e077b858 to your computer and use it in GitHub Desktop.
Quick Save JPEG to Desktop
//Cobbled together from:
//http://feedback.photoshop.com/photoshop_family/topics/quick_save_as
//http://www.polycount.com/forum/showthread.php?t=85425
#target photoshop;
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
var docName = thedoc.name;
if (docName.indexOf(".") != -1) {
var basename = docName.match(/(.*)\.[^\.]+$/)[1]
} else {
var basename = docName
}
//getting the location, if unsaved save to desktop;
// try {
// var docPath = thedoc.path
// } catch (e) {
// var docPath = "~/Desktop"
// }
var docPath = "~/Desktop"
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 12;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
var filename = docPath + '/' + basename + "-" + getTime() + '.jpg';
thedoc.saveAs((new File(filename)), jpegOptions, true);
};
function getTime(){
var currentTime = new Date();
//Make single-digit mins show up as 6:01 and not 6:1
var minutes = currentTime.getMinutes();
if (minutes < 10) {
minutes = "0" + minutes;
}
var timeStamp = currentTime.getFullYear() + "-"
+ (currentTime.getMonth() + 1) + "-"
+ currentTime.getDate() + "-"
+ currentTime.getHours() + "."
+ minutes + "."
+ currentTime.getSeconds() + "."
+ currentTime.getMilliseconds();
return timeStamp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment