LinuxCommandLibrary

winicontopam

Convert Windows icon files to PAM image

TLDR

Read an ICO file and convert the best quality image contained therein to the PAM format

$ winicontopam [path/to/input_file.ico] > [path/to/output.pam]
copy

Convert all images in the input file to PAM
$ winicontopam [[-al|-allimages]] [path/to/input_file.ico] > [path/to/output.pam]
copy

Convert the n'th image in the input file to PAM
$ winicontopam [[-i|-image]] [n] [path/to/input_file.ico] > [path/to/output.pam]
copy

If the image(s) to be extracted contain graded transparency data and an AND mask, write the AND mask into the fifth channel of the output PAM file
$ winicontopam [[-an|-andmasks]] [path/to/input_file.ico] > [path/to/output.pam]
copy

SYNOPSIS

winicontopam [-verbose] [-alphaout={alphaoutfilename}] [-background={rgbvalue}] [-cmap] [-write={pamtype}] [winiconfile [pamoutfile]]

PARAMETERS

-verbose
    Prints details on available image sizes and the selected largest one.

-alphaout={alphaoutfilename}
    Outputs transparency mask as grayscale PAM to specified file.

-background={rgbvalue}
    Sets color (e.g., ffffff for white) for transparent pixels; default white.

-cmap
    Produces colormap PAM with 256 most important colors instead of RGB.

-write={pamtype}
    Sets PAM TUPLTYPE (e.g., rgb, rgba, grayalpha); default rgb.

DESCRIPTION

winicontopam is a utility from the Netpbm graphics toolkit that reads Microsoft Windows icon (.ico) or cursor (.cur) files and converts them to PAM (Portable Arbitrary Map) format.

Windows icons typically contain multiple square images of varying sizes (e.g., 16x16, 32x32, 48x48 pixels) within a single file. By default, winicontopam selects and outputs the largest image as a little-endian RGB PAM.

It handles transparency via an alpha channel option and supports colormap output for efficiency. Transparent pixels can be filled with a custom background color. The tool is lossless where possible, preserving the original pixel data, and is ideal for processing icons in Linux workflows, such as icon theme creation or image manipulation pipelines.

Input is read from a file or stdin; output goes to stdout or a specified file. It's particularly useful for converting proprietary Windows formats to open, editable PAM for further processing with tools like pamtopng or pnmscale.

CAVEATS

Selects only the largest image from multi-size ICO; smaller sizes ignored unless modified source. Limited to Windows ICO/CUR; not BMP or other formats. Colormap mode may lose fidelity on high-color icons.

EXAMPLE USAGE

winicontopam icon.ico out.pam
winicontopam -verbose -alphaout=mask.pam -background=000000 icon.ico
winicontopam -cmap -write=rgba icon.cur | pnmscale 0.5 > small.pam

INPUT NOTES

Reads ICO (icons) or CUR (cursors); stdin supported if no filename given.

HISTORY

Introduced in Netpbm 10.20 (2005) by Akira F. Matsuda; enhanced in later versions for better alpha and TUPLTYPE support. Part of Netpbm suite since early 2000s for cross-platform graphics conversion.

SEE ALSO

pamtowinicon(1), pngtopam(1), icondiff(1)

Copied to clipboard