Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Crop with scripts failed,Help please.

Explorer ,
Sep 02, 2021 Sep 02, 2021

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

TOPICS
Actions and scripting

Views

23

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Sep 02, 2021 Sep 02, 2021
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.

Likes

Translate

Translate
Adobe Community Professional ,
Sep 02, 2021 Sep 02, 2021

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.

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 02, 2021 Sep 02, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much.

I added condition "layer.bounds[0] < layer.bounds[2] && layer.bounds[1] < layer.bounds[3]" before actons,it works perfect.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines