Unknown Layer ID related PSD tags

Started by blue-j, December 14, 2024, 02:33:32 AM

Previous topic - Next topic

blue-j

Photoshop assigns IDs to layers to indicate them internally, as well as group IDs to layer groups.  but they do carry some additional information as well.  Here are the hitherto unknown relevant fields that i am trying to decode:

'lyid' LayerIDs?
0x0414 IDsBaseValue?
0x0400 TargetLayerID?
0x042d LayerSelectionIDs?
0x0430 LayerGroupsEnabledID?

for Layer ID the documentation seems clear to me: the usual 8BIM, then the key lyld, then 4 bytes, then the ID.  each of these is 4 bytes long.

Layer IDs are always unique, and always sequential.  that is, a document will never use the same Layer ID more than once.  that's what this:

0x0414   IDsBaseValue?

is all about.  this is the last layer ID used, so when the file is opened, the next Layer ID assigned will be this base value +1.  this is useful information because it conveys how many layers have been made before, even if they are now deleted (there is never a reset).

the documentation for:

0x0400   TargetLayerID?     says:

QuoteLayer state information. 2 bytes containing the index of target layer (0 = bottom layer).

i believe this has to do with layers that are in a selected state when saved.  the "target layer" is the topmost selected layer ID i think.  as the doc states, these start as 0-indexed, with the bottom layer being index 0.  if there is a layer group (folder) in the stack, then the point at which the layer group starts going from bottom (0) to top counts as an ID.

so, for example, if you created a new image with 3 layers then another 3 layers in a group on top (we always count bottom to top) then the topmost layer would start with an ID of 7.  if you had the same exact layers and no group, then the topmost layer would have an ID of 6.  but target layer ID ONLY lists the topmost SELECTED layer's ID, even if there are many selected.

once layers are moved, they retain their IDs, so position is tracked otherwise.  so these are NOT positional IDs we are referring to really.  i consider this field to be largely useless except internally perhaps, but i reserve the right to be wrong.  maybe "target" means something more than i suggest?


then we have:

0x042d   LayerSelectionIDs?

which provides the full list of layers that are selected when saved, but just to keep things fun, these are NOT 0-indexed to start.  the background layer gets an ID of 1 to start.  i would name this SelectedLayerIDs personally.


0x0430   LayerGroupsEnabledIDs?

QuoteLayer Group(s) Enabled ID. 1 byte for each layer in the document, repeated by length of the resource. NOTE: Layer groups have start and end markers

the use of this one is puzzling to me.  it appears to simply have a "1" for every layer in the document, including the background, and "1 1" for every layer group (that seems to be what is meant for groups have a start and end marker).

example:

1 1 1 1 1 1 1 1 1 1

the file that emits this 7 layers, a background layer, and a layer group.  7 + 1 + 2 = 10 "1"s

dunno what this is all about!  but that is what it appears to denote.  i welcome any collaborators on this!  i just discovered 010 Editor for hex dumps and decoding, and it has a third-party PSD template you can load that basically maps the documentation to the hex.  very cool!

- J




Phil Harvey

I only want to decode tags that provide potentially useful information to ExifTool users.  This is why most of these tags are marked as Unknown.  They aren't really Unknown, they just aren't really metadata.  All of these tags are tending more towards image data than metadata, and I don't want to get into decoding all of the image data.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

blue-j

i would suggest that maybe a few are useful?  let me give the argument a try.

'lyid'    LayerIDs?
0x0414    IDsBaseValue?
0x042d    LayerSelectionIDs?

and change LayerSelectionIDs to SelectedLayerIDs IMHO

first, there are the people providing PSD tools, like psd-tools, ImageMagick, PSD.rb, PSD.js, etc.

they can count on ExifTool quite often to crack the code, and knowing Layer IDs and how IDs are iterated allows people to programmatically insert layers with proper IDs.

it also allows digital forensic specialists to note when something is awry, if the ID base value is unusually high for an allegedly untouched image, for example.

anyone who want to show the layer structure in their UI (DAM makers mainly) also may leverage the data stored that Adobe doesn't even show - like date modified per layer, which is damn useful.

we work with a lot of large companies, and some have strict specifications on their file structure for PSDs, and exposing this data could help efforts to programmatically check files for adherence.

developers and digital forensics folks routinely rely on ExifTool, so their needs are not edge cases, i would suggest.  i of course defer to your judgment here, and honor your experience and wisdom on what to include - something you've done excellently for years.

- J

blue-j

i just realized, these are already decoded and extractable with Exiftool.  the only thing you'd do would be take off the Unknown designation, and consider changing the name as i suggested.  or not.  : )

- J

Phil Harvey

I would rather not change the names at this point.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).