Copy link to clipboard
Copied
I have the following (supposedly simple) JSX code that I run after creating a new blank Photoshop document:
var meta = app.activeDocument.activeLayer.xmpMetadata
$.writeln(meta.rawData)
However, for some reason, the only thing I can get out of this is an error on the second line saying "'value' property is missing". Even trying to view the object contents with the ESTK Data Browser makes it break (it cannot display more than the "parent" field, after that it shows the same error in the Data Browser itself).
However, if I try to set the `meta.rawData` field to some random string before trying to read it in any way, it works (well, I get back my own string). Obviously, this is not a valid solution, as I want to read the field before setting it to anything else.
Does anyone know if this is a bug (it certainly looks like it!) and how to workaround it?
Thanks in advance
Put the read into try-catch. If it throws an error the key isn't exists yet. If you set it, then write, close, reopen the .psd, the value will be there.
Copy link to clipboard
Copied
Put the read into try-catch. If it throws an error the key isn't exists yet. If you set it, then write, close, reopen the .psd, the value will be there.
Copy link to clipboard
Copied
Yeah, I forgot to say that this is exactly what I'm doing right now, but it still feels like a bug?
Copy link to clipboard
Copied
Hehe, not just this seems like a bug in ToolVM DOM We have to hack our way through. I often feel myself in an abandoned sanitarium.
By the way: the generator's backdoor/brain surgery approach is seems like much more useable in many cases than pure .jsx.
Copy link to clipboard
Copied
Well, not sure about what Tool DOM is, but if you mean this only happens in ELTK, I get the same error (well, I assume as I only get "ExtendScript error") inside my HTML panel.
What is that generator/backdoor you mention?
Copy link to clipboard
Copied
I call the PS Extendscript interpreter "ToolVM" and the HTML panels's v8 javascript engine "PanelVM". As I remember I saw this naming somewhere.
The backdoor is generator-core which can run from standalone nodejs or from node enabled panel. It can send .jsx snipplets via socket to PS and get back values from it with the help of Kevlar interface. It can retrieve the full document structure around 150 ms and has methods to store/retrieve custom, json data in the .psd.
Check out the
Generator.prototype.getLayerSettingsForPlugin = function (documentId, layerId, pluginId)
Generator.prototype.setLayerSettingsForPlugin = function (settings, layerId, pluginId)
methods.
Copy link to clipboard
Copied
Ah, that's very interesting, thank you! And that's what I'm actually doing, storing some custom JSON on the xmpMetadata object (I know it's supposed to be XML, but Photoshop doesn't seem to care, and it's easier for me to create, plus only my external tools are going to interpret this data from the PSD itself)
I'll take a look, thanks again!
P.D. This whole ecosystem seems in a broken/undocumented/abandoned state, I really concur with your sanitarium statement of before...