Copy link to clipboard
Copied
What I'm hoping to accomplish is as follows:
Draw a line, then
Press a hotkey to Play an Action.
The action needs to save an incremental .jpeg
and then select the previous history state.
The goal being that everytime I try to undo a mark, I have a copy of the image with the mistake, creating a record of the process. I have absolutely no knowledge of scripting. I will basically use this as an alternative undo key.
I am working on a project in which I need to save "snapshots" of my progress. Basically I'm working on a digital sketchbook and am trying to record the progress of every mark I make on the page. My workflow for this project entails the drawing of a line and then selecting of the previous history state, erasing the lines I do not want and layering the ones I do. The idea being that I can catologue my entire workflow and progress in a series of images to post to my sketchbook blog. This is part of a longterm project to track improvement and I'm am following this ideal for multitudes of images each day.
I suppose all I'm asking for here is a script that will run and save a .jpeg of the current .psd, adding a "_001, _002, _003" suffix to the filename, checking to see if the current suffix is taken and changing to the next one. This way I can catalogue the "snapshots" of mutiple images in the same folder.
Using Photoshop CS5 on OSX Snow Leopard.
Try this....
#target photoshop
main();
function main(){
if(!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try{
var savePath = activeDocument.path;
}catch(e){
alert("You must save this document first!");
}
var fileList= savePath.getFiles(Name +"*.jpg").sort().reverse();
var Suffix = 0;
if(fileList.length){
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix= zeroPad(Suffix + 1, 3);
var saveFile = File(savePath + "/" + Name + "_"
...
Copy link to clipboard
Copied
Try this....
#target photoshop
main();
function main(){
if(!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try{
var savePath = activeDocument.path;
}catch(e){
alert("You must save this document first!");
}
var fileList= savePath.getFiles(Name +"*.jpg").sort().reverse();
var Suffix = 0;
if(fileList.length){
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix= zeroPad(Suffix + 1, 3);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".jpg");
SaveJPEG(saveFile, 8);
}
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
};
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};
Copy link to clipboard
Copied
Hello Paul,
The script works flawlessly to accomplish what I was hoping for! Thanks so much for your time!!
I do have one more question. I'm writing a blog post noting what I'm trying to do with my sketchbook and would like to post the script, as well as attribute it to you. First, is this okay? And second, if so, do you have a page or blog you would like me to link? Otherwise I'll just link to this thread.
Copy link to clipboard
Copied
No problem Josh, I don't have a blog as such, although I have a few scripts here that might be use...
Copy link to clipboard
Copied
Okay, I linked to the page you provided and credited you for the script. I'll be sure to give those scripts a closer look in the future. Here's a link for the post if you wan to check it out: keeping-digital-record-photoshop
Thanks again!!!
Copy link to clipboard
Copied
No problem Josh, I don't have a blog as such, although I have a few scripts here that might be use...
Paulās scripts are now hosted here:
Copy link to clipboard
Copied
Here is a copy of the incremental JPEG save script that I just hacked into saving out a PSD file:
// https://forums.adobe.com/message/4453915#4453915
#target photoshop
main();
function main(){
if(!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try{
var savePath = activeDocument.path;
}catch(e){
alert("You must save this document first!");
}
var fileList= savePath.getFiles(Name +"*.psd").sort().reverse();
var Suffix = 0;
if(fileList.length){
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix= zeroPad(Suffix + 1, 3);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".psd");
SavePSD(saveFile);
}
function SavePSD(saveFile){
// http://jongware.mit.edu/pscs5js_html/psjscs5/pc_PhotoshopSaveOptions.html
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
psdSaveOptions.layers = true;
psdSaveOptions.annotations = true;
psdSaveOptions.spotColors = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
};
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};
Copy link to clipboard
Copied
Here is a copy of the incremental JPEG save script that I just hacked into saving out a TIFF file:
// https://forums.adobe.com/message/4453915#4453915
#target photoshop
main();
function main(){
if(!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try{
var savePath = activeDocument.path;
}catch(e){
alert("You must save this document first!");
}
var fileList= savePath.getFiles(Name +"*.tif").sort().reverse();
var Suffix = 0;
if(fileList.length){
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix= zeroPad(Suffix + 1, 3);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".tif");
SaveTIFF(saveFile);
}
function SaveTIFF(saveFile){
// http://jongware.mit.edu/pscs5js_html/psjscs5/pc_TiffSaveOptions.html
// http://jongware.mit.edu/pscs5js_html/psjscs5/pe_TIFFEncoding.html
// TIFFEncoding.NONE
// TIFFEncoding.JPEG
// TIFFEncoding.TIFFLZW
// TIFFEncoding.TIFFZIP
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.byteOrder = ByteOrder.IBM;
tiffSaveOptions.transparency = true;
tiffSaveOptions.layers = true;
tiffSaveOptions.layerCompression = LayerCompression.ZIP;
tiffSaveOptions.interleaveChannels= true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.spotColors = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};