Runs in both NodeJS and the browser (using browserify). There are still some pieces missing that are present in PSD.rb, such as layer comp filtering, a built-in renderer, and many layer info blocks. The eventual goal is full feature parity with PSD.rb.

To access the document as a tree structure, use psd.tree() to get the root node. From there, work with the tree using any of these methods:

root(): get the root node from anywhere in the tree

isRoot(): is this the root node?

children(): get all immediate children of the node

hasChildren(): does this node have any children?

childless(): opposite of hasChildren()

ancestors(): get all ancestors in the path of this node (excluding the root)

siblings(): get all sibling tree nodes including the current one (e.g. all layers in a folder)

nextSibling(): gets the sibling immediately following the current node

prevSibling(): gets the sibling immediately before the current node

hasSiblings(): does this node have any siblings?

onlyChild(): opposite of hasSiblings()

descendants(): get all descendant nodes not including the current one

subtree(): same as descendants but starts with the current node

depth(): calculate the depth of the current node (root node is 0)

path(): gets the path to the current node

If you know the path to a group or layer within the tree, you can search by that path. Note that this always returns an Array because layer/group names do not have to be unique. The search is always scoped to the descendants of the current node, as well.

PSD files also store various pieces of information in "layer info" blocks. See this file for all of the possible layer info blocks that PSD.js parses (in LAYER_INFO). Which blocks a layer has varies from layer-to-layer, but to access them you can do: