LinuxCommandLibrary

pbmtoicon

Convert PBM images to Windows icons

TLDR

View documentation for the current command

$ tldr pbmtosunicon
copy

SYNOPSIS

pbmtoicon [-nograys] [-compress] [-variable name] [pbmfile]

PARAMETERS

pbmfile
    The path to the input PBM image file. If not specified, pbmtoicon reads from standard input.

-nograys
    When generating XPM output, this option prevents the emission of gray pixels, ensuring only black and white colors are used. This is often the default behavior for PBM conversions.

-compress
    For XPM output, this option instructs the command to produce a compressed XPM file, which can reduce file size.

-variable name
    Specifies the C variable name to be used for the image data in the output file. By default, it uses "image_bits".

DESCRIPTION

pbmtoicon is a utility from the Netpbm package that converts a Portable BitMap (PBM) image file into an X11 icon file. X11 icon files are typically represented as XBM (X BitMap) or XPM (X Pixmap) formats, which are C source code files containing pixel data suitable for embedding directly into X11 applications.

The PBM format handles monochrome (black and white) images, which makes it ideal for direct conversion to the simple bitmap structure of XBM files. While it can also produce XPM files, it leverages only the black and white capabilities. This command is particularly useful for preparing small, monochrome graphical assets for use in X11 programming projects, where icons, cursors, or simple splash screens might be required in a C-compatible format. It processes the input PBM data and outputs the corresponding C array declaration to standard output, making it easy to integrate into build processes or direct source code compilation.

CAVEATS

This command is designed for PBM (monochrome) input only. If you need to convert color or grayscale images to XPM, you would typically use other Netpbm tools like ppmtoimg or pnmtopam followed by specialized tools.
The output is a C source file; it's not a direct image file you can open with an image viewer without compilation or parsing.
Output format implicitly depends on the input size and simple B/W; for complex color images, it's not the right tool.

OUTPUT FORMAT

The command produces XBM (X BitMap) or XPM (X Pixmap) formatted C source code to standard output. The output will contain a C array definition representing the image's pixel data.

STANDARD INPUT/OUTPUT

If the pbmfile argument is omitted, pbmtoicon reads the PBM image data from standard input. The converted X11 icon data is always written to standard output. This makes it suitable for use in pipelines.

HISTORY

pbmtoicon is part of the extensive Netpbm package, which originated from the Pbmplus toolkit created by Jef Poskanzer. Pbmplus was developed in the late 1980s to provide a standard set of tools for manipulating various image formats, particularly in the Unix environment. pbmtoicon specifically addresses the need to prepare simple monochrome graphics for X11 applications, which were prevalent during the early days of graphical Unix workstations. Its continued inclusion in Netpbm reflects the enduring need for command-line image processing utilities, especially for developers working with embedded graphics or legacy X11 codebases.

SEE ALSO

pbm(5), xbm(5), xpm(5), pamtopnm(1), ppmtoimg(1), netpbm(1)

Copied to clipboard