Trying To Get Layer Kind

I am trying to determine if the top layer is a pixel based layer ( Not any adjustment or text) type of layer.

I am using the following which seems to log the LayerKind as a number. Is there anyway of finding out what these numbers refer to.

const app = require("photoshop").app;
const currentDocument = app.activeDocument
const layers = currentDocument.activeLayers;
const topLayer = layers[0]

console.log(topLayer.kind)

Thanks

1 Like

I just got done making a list for myself just by testing each layer type. I think this is all of them unless there is a #12 for another layer type I forgot to test.

1 - Bitmap layer, including background
2 - Adjustment layer (levels, hue/sat, curves, ect)
3 - Text
4 - Shape
5 - Smart Object
6 - Video
7 - Frame or Group
8 - 3D
9 - Gradient Fill
10 - Pattern Fill
11 - Color Fill

2 Likes
export enum LayerKind {
  any = 0,
  pixel = 1,
  adjustment = 2,
  text = 3,
  vector = 4,
  smartObject = 5,
  video = 6,
  group = 7,
  threeD = 8,
  gradient = 9,
  pattern = 10,
  solidColor = 11,
  background = 12,
  groupEnd = 13
}

Groups actually occupy two layer spaces internally (group start and group end), so if that’s your setup…
image
…the layerKind at indices 0-3 would be
0: Pixel (LayerKind 1)
1: Group End (LayerKind 13)
2: Group (LayerKind 7)

Seems like backgrounds only result in LayerKind 12 when they’re the only layer in the document

2 Likes

Thanks @simonhenke and @ddbell this has helped a great deal.

Thanks for the clarification on 12 and 13. 12 will be helpful for sure trying to figure out if single layer files are flattened or not.

For 7, do you know if there is any way to differentiate between a frame layer or group folder? They both read as 7.

image
Comparing a group with vector mask with a frame, these are the only differences. Seems like AGMStrokeStyleInfo is the only property to distinguish those two, as a group can’t have a stroke.
So if you check for the layerKind and this property you should be able to identify a frame, theoretically

Thanks, that will be helpful down the road because I may need to use frames for an upcoming project I have scheduled in a couple of months.