LinuxCommandLibrary

xwdtopnm

Convert X Window Dump (XWD) images to PNM

TLDR

Convert a XWD image file to PBM

$ xwdtopnm [path/to/input_file.xwd] > [path/to/output_file.pnm]
copy

Display information about the conversion process
$ xwdtopnm [[-verb|-verbose]] [path/to/input_file.xwd] > [path/to/output_file.pnm]
copy

Display the contents of the X11 header of the input file
$ xwdtopnm [[-h|-headerdump]] [path/to/input_file.xwd] > [path/to/output_file.pnm]
copy

SYNOPSIS

xwdtopnm [xwdfile]
xwdfile: Path to the XWD image file. If omitted, input is read from standard input.

DESCRIPTION

xwdtopnm is a utility from the Netpbm suite that converts an X Window System image dump file (XWD format) into a Portable Anymap (PNM) image. The PNM format is a generic term encompassing PBM (Portable Bitmap for monochrome images), PGM (Portable Greymap for grayscale images), and PPM (Portable Pixmap for color images).

This tool is crucial for interoperability, allowing images captured from the X Window System (e.g., using the xwd command) to be processed, manipulated, or viewed using standard image tools that support the widely used PNM formats. It reads the XWD data from standard input by default or from a specified file, and writes the resulting PNM image to standard output, enabling easy piping with other Netpbm utilities or image processing tools.

CAVEATS

xwdtopnm expects a valid XWD file as input. Issues may arise with corrupted XWD files or very old/uncommon XWD format variations. As part of the Netpbm suite, it is often used in pipelines, and its success depends on the preceding command providing a correct XWD stream. It does not provide any specific error messages for malformed input beyond what the Netpbm library might generate.

TYPICAL USAGE

The most common usage involves piping the output of the xwd command directly into xwdtopnm. For example, to capture a window and convert it to a PNG file:
xwd -id $(xwininfo | grep "Window id:" | awk '{print $4}') | xwdtopnm | pnmtopng > screenshot.png
This demonstrates its role as an intermediate converter in a larger image processing workflow within the Unix command-line environment.

HISTORY

xwdtopnm is an integral part of the Netpbm project, a comprehensive toolkit for manipulating graphic images. Netpbm itself evolved from the original pbmplus package, which was created by Jef Poskanzer in the late 1980s. The Netpbm tools, including xwdtopnm, are known for their simplicity, Unix philosophy adherence (doing one thing well), and their ability to be chained together in powerful pipelines for complex image processing tasks. Its development has focused on maintaining compatibility and robustness across various X Window System versions and image depths.

SEE ALSO

xwd(1), xwud(1), pnm(5), pnmtoxwd(1), netpbm(1)

Copied to clipboard