Copy link to clipboard
Copied
Hi~,
when i use script command 'app.activeDocument.crop(layer.bounds)', error message popout:The command cannot be completed because the affected area is empty or does not overlap the canvas.
before this action, i have set all layers invisible, then:
layer.visible = true;
app.activeDocument.activeLayer = layer;
app.activeDocument.crop(layer.bounds);//this cause error
_saveImage(ffname);//export layer as png
layer.visible = false;
What should i do?
Thanks so much
Target a layer that has some Pixels. You document actives layer seems void of pixels. Its bounds is null. The Layer object you targeted " app.activeDocument.activeLayer = layer;" seems to be empty or one the is data for some adjustment or all of the layer pixels are off canvas none are positioned over the canvas. Crop can not delete the document canvas. Is not a valid operation.
Copy link to clipboard
Copied
Target a layer that has some Pixels. You document actives layer seems void of pixels. Its bounds is null. The Layer object you targeted " app.activeDocument.activeLayer = layer;" seems to be empty or one the is data for some adjustment or all of the layer pixels are off canvas none are positioned over the canvas. Crop can not delete the document canvas. Is not a valid operation.
Copy link to clipboard
Copied
Thank you so much.
I added condition "layer.bounds[0] < layer.bounds[2] && layer.bounds[1] < layer.bounds[3]" before actons,it works perfect.