xwd is a file format written by eponymous X11 screen capture
application (xwd stands for "X Window Dump"). Typically, an average
user transforms xwd format into something more widespread by any of
pnmto... utilities right away.
xwd format itself provides a raw uncompressed bitmap with some metainformation, like pixel format, width, height, bit depth, etc. Note that technically format includes machine-dependent fields and thus is probably a poor choice for true cross-platform usage.
This page hosts a formal specification of xwd (X Window Dump) bitmap image using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.