History states disappear

,

I use this line of code:

require(‘photoshop’).app.activeDocument.historyStates

Which is fine for iterating the history and doing what I need to. However, the user saves their work as a PSD, closes PS and later on reopens the PSD. History states is now empty (shown by the empty history pane) and when I export, I now have no history being passed.

I notice if the history logging has been switched on (in preferences) that I can view the history, which has been restored in the history (File>File Info). Presumably this is from the metadata.

My first question is is there a way to access this history from UXP like the above line of code does?

Secondly, if not, how would I go about accessing the meta data? I could write a manual parser for the XML and extract the history myself.

@kerrishotts @Jarda

Resolved it.

    const app = require("photoshop").app;
    const { XMPMeta, XMPConst } = require("uxp").xmp;
    const xml = getDocumentXMP();
    const xmp = new XMPMeta(xml);

    const history = xmp.getProperty(XMPConst.NS_PHOTOSHOP, "History");

Then iterate the history.value.

1 Like