Hey Guys, I’m currently working on a PS UXP plugin containing a backend, and I need to read/update the layer content each time the front-end (I mean, the plugin) submit a request and received the new processed results. But the processing time is tooooo long…
Now for reading a layer to memory, I can only do this by:
- hide all layers except the selected layer by
layer.visible = false
- save the whole document to a file by
document.save()
- read the file to memory by
file.read({format: uxp.storage.formats.binary})
And for loading the received image to layer, the process is similar:
- save the image binary to a file by
storage.file.write(image)
- open the image in a new temp document by
tempDoc = document.open(image)
- extract the new layer to the main doc by
tempDoc.layers[0].duplicate(mainDoc)
This is really a low efficient way, especially when the back and forth need to be repeated many times and it could be worse if the opened document contains nearly 10 layers. The user has to wait for 5 or even more than 10 seconds for every request until all layers have been created or updated (that will be annoying to users ).
I looked at the UXP document but seen there is not such an API could read or write layer easily. And I also searched here but nothing found. Can anyone give me some help or suggestion on this issue?