LinuxCommandLibrary

xwd

Dump an X Window System image

SYNOPSIS

xwd [options ...] > filename.xwd
xwd [options ...]

PARAMETERS

-display display
    Specifies the X server to connect to.

-root
    Dumps the root window of the screen instead of a specific application window.

-id id
    Dumps the window with the specified X resource ID.

-name name
    Dumps the window with the specified WM_NAME property (window title).

-add value
    Adds value to each pixel, primarily for colormap debugging.

-xy
    Uses XY format for dumping pixmaps; the default is Z format.

-frame
    Includes the window manager frame (borders and title bar) in the captured image.

-icmap
    Forces the use of the ideal colormap for the window when dumping.

-nobdrs
    Excludes the window's border from the captured image.

-out file
    Writes the image to the specified file instead of standard output.

-silent
    Suppresses the bell and visual feedback when capturing a window.

-help
    Displays a help message with command usage.

-version
    Displays version information for xwd.

DESCRIPTION

xwd is an X Window System utility designed to dump an image of a window into an X Window Dump (XWD) format file. It provides a low-level method for screen capturing within an X environment. Users can capture either a specific window by its ID or name, or the entire root window (desktop). If no window is explicitly specified, xwd typically changes the cursor to a crosshair, allowing the user to interactively select the desired window by clicking on it.

The output, usually redirected to a file (e.g., xwd > screenshot.xwd), is in the .xwd format. This format is native to the X Window System and can be viewed with tools like xwud or, more commonly, converted to widely supported image formats such as PNG or JPEG using utilities like ImageMagick's convert command. xwd is a fundamental tool for debugging X applications, documenting user interfaces, or taking screenshots in minimalist X setups.

CAVEATS

The .xwd file format generated by xwd is specific to the X Window System and is not directly viewable by most common image viewers without prior conversion. Colormap issues can sometimes lead to unexpected color representation in the captured image, especially with older X applications or complex display setups.

XWD FILE FORMAT

The XWD (X Window Dump) format is a simple raster image format tailored for the X Window System. It stores raw pixel data along with X-specific information, such as the visual type, depth, and colormap details of the captured window. This makes it particularly useful for X protocol-level analysis and debugging.

COMMON USAGE WITH IMAGEMAGICK

While xwd produces its native format, it is often used in conjunction with ImageMagick's convert command for immediate format conversion. A common pattern is piping the output of xwd directly to convert: xwd -silent -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) | convert xwd:- active_window.png. This captures the currently active window and saves it as a PNG file.

HISTORY

xwd is an integral part of the X.Org utilities, dating back to the early development of the X Window System. It has served as a foundational tool for screen capture and display debugging in X environments long before more sophisticated graphical screenshot utilities became common. Its continued existence reflects the need for a low-level, direct interaction with the X server's display capabilities.

SEE ALSO

xwud(1), convert(1), import(1), scrot(1)

Copied to clipboard