A question about get layer buffer

Hello experts
My goal is to get the layer’s buffer data and upload it to our server. This is my work step:

It can be seen that my work relies on the operation of copying the layer, but in some cases, the layer cannot be copied. PS tells me that the operation cannot be completed because of a program error. In fact, I can hardly do most operation on the layer, including simply moving this layer or converting to a smart object layer(sometimes works).


After checking, I found that there is a child layer seems to be dirty.


After deleting it, I can continue to work, paste to new document and bla bla…

I don’t know how my user generated this dirty layer, but I want to know, besides reminding the user to find and delete this layer, is there any other way I can accomplish my goal?
for example, how to check or fix this kind of layer by program

You could loop all layers and read out their bounds. Based on that information, you could delete all empty layers or those outside of the document/artboard.

It only appears to be displayed outside the artboard, but as a child of a certain layer in the tree structure.
The strange thing is that I checked its bounds and they are indeed 0, but there are valid bounds value that seem to be disabled in the property panel.

I will do this like you said if there is no other way, but I hope to get a better solution from Adobe to achieve my goal, rather than being as complicated as I am doing now.

Anyway, thank you Simon.

Another option might be to

  1. Duplicate the layer to a new document
  2. Merge group if applicable

I would expect the clipboard would behave better or you can save to a temp file for uploading.