• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

174

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

Community Expert , 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.

Votes

Translate

Translate
Adobe
Community Expert ,
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

Votes

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.

Votes

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