pamtowinicon
Convert PAM images to Windows icon format
TLDR
Convert a PAM image file to an ICO file
Encode images with resolutions smaller than t in the BMP format and all other images in the PNG format
Make all pixels outside the non-opaque area black
SYNOPSIS
pamtowinicon [-alpha] [-output filename] [-sizes widthxheight[,widthxheight...]] [-colors colorspec[,colorspec...]] [pbmfile...]
OR
pamtowinicon [-alpha] [-output filename] [-sizes widthxheight[,widthxheight...]] [-colors colorspec[,colorspec...]] < input_pbm_file
PARAMETERS
-alpha
Forces output icon images to have an alpha channel, even if the input doesn't explicitly contain one. This is crucial for transparent icons.
-output filename
Specifies the output .ICO file name. If omitted, the icon data is written to standard output.
-sizes widthxheight[,widthxheight...]
A comma-separated list of desired dimensions (e.g., 16x16, 32x32, 48x48) for the icon entries. pamtowinicon will scale input images to these specified sizes.
-colors colorspec[,colorspec...]
A comma-separated list of color depth specifications. colorspec can be monochrome, 16, 256, or true. This determines the color palette for each icon entry.
DESCRIPTION
pamtowinicon is a powerful utility from the Netpbm image processing toolkit. It enables the conversion of Netpbm format images (PAM, PNM, PBM, PGM, PPM) into a Windows Icon (.ICO) file. A key feature is its ability to embed multiple image representations within a single .ICO file, allowing the icon to display optimally at various sizes and color depths (e.g., 16x16, 32x32, 48x48 pixels with different color palettes). This is particularly useful for creating icons that adapt well to different display contexts, such as desktop shortcuts or web favicons.
The command can take one or more Netpbm files as input, each representing a different image layer for the icon, or it can process a single Netpbm file that contains multiple images. It provides options for specifying the desired sizes and color depths for the icon entries, offering flexibility in creating professional-quality icons.
CAVEATS
The Netpbm input images should ideally be square and have appropriate dimensions for typical icon sizes to avoid significant distortion during scaling.
While pamtowinicon can create icons with alpha channels, older Windows versions or applications might not fully support them, potentially leading to a loss of transparency or display artifacts.
INPUT FORMAT FLEXIBILITY
pamtowinicon can accept any Netpbm format (PBM, PGM, PPM, PAM) as input. If the input is not a PAM file, it is automatically converted to PAM internally before processing, ensuring full support for alpha channels and arbitrary depths.
BEST PRACTICES FOR ICON CREATION
For optimal results, it's recommended to provide a high-resolution, square source image as input. Then, use the -sizes and -colors options to let pamtowinicon generate the various icon entries (e.g., 16x16, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256) with appropriate color depths (e.g., true for larger sizes, 256 or 16 for smaller ones) from this single source. This ensures consistency across different icon sizes.
HISTORY
pamtowinicon is part of the extensive Netpbm project, a suite of graphics utilities that originated in the early 1990s. The Netpbm toolkit is renowned for its modular design, where small, specialized programs perform specific image transformations. pamtowinicon was developed to address the specific need of converting general image formats into the proprietary Windows Icon (.ICO) format, enabling Linux and Unix users to create icons compatible with Windows environments without needing Windows-specific software. Its development reflects the Netpbm philosophy of providing versatile, command-line tools for a wide range of image manipulation tasks.