• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to incrementally save images using a hotkey

New Here ,
May 31, 2012 May 31, 2012

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.

TOPICS
Actions and scripting

Views

3.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , May 31, 2012 May 31, 2012

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 + "_"

...

Votes

Translate

Translate
Adobe
Valorous Hero ,
May 31, 2012 May 31, 2012

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;

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 31, 2012 May 31, 2012

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 31, 2012 May 31, 2012

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...

scriptsrus.talktalk.net

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2012 Jun 01, 2012

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!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2017 Aug 28, 2017

Copy link to clipboard

Copied

LATEST

No problem Josh, I don't have a blog as such, although I have a few scripts here that might be use...

scriptsrus.talktalk.net

 

Paul’s scripts are now hosted here:

 

GitHub - Paul-Riggott/PS-Scripts: Photoshop Scripts

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2017 Aug 28, 2017

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;

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 28, 2017 Aug 28, 2017

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;

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines