Skip to main content
Inspiring
August 17, 2021
Answered

Check if selected area is empty

  • August 17, 2021
  • 1 reply
  • 1991 views

I am trying to create a script that will be executed based on whether the decision is true.  I want to add adjustment curve for each channel particularly (CMYK), only if that color exists on selected layer. It should look like on image below.

Thanks in advanced

This topic has been closed for replies.
Correct answer milevic

I found the answer

Script: Delete selected layer, if empty.

1 reply

milevicAuthorCorrect answer
Inspiring
August 17, 2021
Kukurykus
Legend
August 17, 2021

Can you explain how that solution solves your problem if you look for empty channels, not layers?

milevicAuthor
Inspiring
August 19, 2021

First I created curves with selection of each channel separately, then I used this script from the link to check each of those four (curve) layers and it works...

It may not be the most aesthetically pleasing solution, but for me as someone who is just researching scripting, it was enough that this script cover my needs 🙂

 

 

 

var layer = app.activeDocument.activeLayer;
var layerName = layer.name;
if (!(layer.allLocked || layer.pixelsLocked || layer.positionLocked || layer.transparentPixelsLocked || (0 !== layer.linkedLayers.length))) { 
    if ((0 === layer.bounds[2] && (0 === layer.bounds[3]))) {
        layer.remove();
    }
    else {
////// do something
 } 
}