skip to Main Content

I’m new to Photoshop JSX scripting. Until now I did script a little “hello world” that saves a jpg image of the first history snapshot.

What I want is to know the number of history snapshots present in the active image but I can’t find any good info or example.

2

Answers


  1. Chosen as BEST ANSWER

    Here is the solution (Thanks to c.pfaffenbichler):

    xvar myDoc = app.activeDocument;
    var theHist = myDoc.historyStates;
    var theSnaps = new Array;
    for (var m = 0; m < theHist.length; m++) {
    var theState = theHist[m];
    if (theState.snapshot == true) {theSnaps.push(theState)}
    };
    alert (theSnaps.length);
    

    Nice. Isn't it?


  2. You need to iterate through Document.HistoryStates and test the boolean called snapshot for each one – it is true if the state is a snapshot.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search