ImageMagick accepts layer names up to 256 characters. We suspect if its returning 31 characters the layer name is truncated in the PSD image itself. If you suspect otherwise, post a URL to one of your images so we can take a closer look at the problem.