The output I get from a capture of the file browser: xwd -name CVandXdo - File Browser -out capture.xwdDoesn't match the specification defined for xwd files:http://www.fileformat.info/format/xwd/egff.htmI plan on parsing the output for an image recognition program. But I cannot localize the xwd header. I need to know where the pixels start and how many rows and columns there are.Here is the beginning of the xwd file using a hex-editor. The xwd command has put another header before I think, but I'm unable to find its documentation. I assume there is one header from 0x00 to 0x7c, but the actual xwd format header doesn't appear to begin after it.00000000: 0000 007c 0000 0007 0000 0002 0000 0018  ...|............00000010: 0000 01f1 0000 01b5 0000 0000 0000 0000  ................00000020: 0000 0020 0000 0000 0000 0020 0000 0020  ... ....... ... 00000030: 0000 07c4 0000 0004 00ff 0000 0000 ff00  ................00000040: 0000 00ff 0000 0008 0000 0100 0000 0100  ................00000050: 0000 01f1 0000 01b5 0000 055e 0000 007a  ...........^...z00000060: 0000 0000 4356 616e 6458 646f 202d 2046  ....CVandXdo - F00000070: 696c 6520 4272 6f77 7365 7200 0000 0000  ile Browser.....00000080: 0000 0000 0000 0701 0001 0101 0101 0101  ................This is the same file, after I opened it in GIMP and saved it again.00000000: 0000 0064 0000 0007 0000 0002 0000 0018  ...d............00000010: 0000 01f1 0000 01b5 0000 0000 0000 0001  ................00000020: 0000 0020 0000 0001 0000 0020 0000 0018  ... ....... ....00000030: 0000 05d4 0000 0005 00ff 0000 0000 ff00  ................00000040: 0000 00ff 0000 0008 0000 0000 0000 0000  ................00000050: 0000 01f1 0000 01b5 0000 0040 0000 0040  ...........@...@00000060: 0000 0000 edec ebed eceb edec ebed eceb  ................Can someone find me this arcane xwd documentation, or perhaps its output implementation, that explain its behaviour? All my google-searching have resulted in tutorials in how to take screenshots using xwd.
xwd output - unknown header
linux;command line;x11
The include file /usr/include/X11/XWDFile.h which is part of X11 holds more information. I found this file in rpm xorg-x11-proto-devel on my system. In particular, the HeaderSize which your link says is always 40 is incorrect. The header file says header_size = SIZEOF(XWDheader) + length of null-terminated window name. Further useful comments in the file areNull-terminated window name follows the above structure.   Next comes XWDColor structures, at offset XWDFileHeader.header_size in   the file.  XWDFileHeader.ncolors tells how many XWDColor structures   there are.Here's a bit of python to read the start of an xwd file and print some of this information. It calculates the offset to the first image pixels:#!/usr/bin/pythonimport sys, structXWDColorlen = 4*3*2+2*1MSBFirst = 1class Xwd:    def __init__(self,data):        (self.header_size,        self.file_version,        self.pixmap_format,        self.pixmap_depth,        self.pixmap_width,        self.pixmap_height,        self.xoffset,        self.byte_order,        self.bitmap_unit,        self.bitmap_bit_order,        self.bitmap_pad,        self.bits_per_pixel,        self.bytes_per_line,        self.visual_class,        self.red_mask,        self.green_mask,        self.blue_mask,        self.bits_per_rgb,        self.colormap_entries,        self.ncolors,        self.window_width,        self.window_height,        self.window_x,        self.window_y,        self.window_bdrwidth) = struct.unpack(>25I,data[:100])f = file(sys.argv[1])data = f.read()xwd = Xwd(data)print(header_size %d  ncolors %d % (xwd.header_size, xwd.ncolors))offset = xwd.header_size+xwd.ncolors*XWDColorlenprint(offset %d 0x%x % (offset,offset))print(bits_per_pixel %d % xwd.bits_per_pixel)if xwd.bits_per_pixel==32:    if xwd.byte_order==MSBFirst:        fmt = >I    else:        fmt = <I    for i in range(20):        print(%08x % struct.unpack(fmt,data[offset:offset+4]))        offset += 4Applied to the data example you provided, it saysheader_size 124  ncolors 256offset 6780 0x1a7cbits_per_pixel 32I see there is also a perl pod to investigate xwd images.