As an alternative to the plugin approach (which might work), I've already written a standalone program (GPL) that does what you need: http://telegraphics.com.au/svn/psdparse/trunk
(Extracts every layer of a PSD/PSB as a PNG file. Metadata such as layer sizes and positions is optionally extracted to XML.)
Since the PSD documentation is so incomplete, incorrect, and confusing (assuming you can obtain it at all), you would need several hundred hours to duplicate this effort. A number of things are not documented and therefore not supported by this program, but it is substantially compatible with PSDs at least through CS2.
... View more