14 Replies Latest reply on Mar 1, 2017 8:25 AM by Mouky

    Detect colors and alpha in document/layers

    Mouky

      Hi everyone,

       

      I'm trying to make a script that make a folder with each layers (normal and solidfill) as images and get text in text layers and put informations about layers in a JSON files. It is to use it after in a zip file to make something behind.
      The thing is, I'm having some problems.

       

      First, I duplicate and crop layer by layer with bounds informations to make the image.
      The problem is, I would like to know if there is some pixels with alpha so I save it as a PNG, if no transparency, then I save it as a JPG.
      Info : i put opacity to 100, so it's not about opacity, but pixels which was not filled;

       

      Then, it happends that my layer is just one rectangle with one color
      I don't know how to know if the layer is fully fill, and only one color
      Cause this kind of layer must not be save as an image, I'll just take informations in a JSON that this layer is a one color rectangle.

       


      So that's my 2 problems
      • Detect alpha/transparency (not opacity) in a layer/document
      • Detect if I have a layer fully fill with only one color

       

       

      Thanks everyone