Skip to main content
The image utility is a command-line tool for converting between image formats, manipulating images, and extracting metadata. It supports multiple image formats and provides various transformation operations.

Supported formats

Input formats

  • PNG - Portable Network Graphics
  • JPEG - Joint Photographic Experts Group
  • GIF - Graphics Interchange Format
  • BMP - Bitmap Image File
  • WebP - WebP image format
  • ICO - Icon format
  • TIFF - Tagged Image File Format
  • PBM/PGM/PPM - Portable Anymap formats

Output formats

  • PNG - With compression level control
  • JPEG - With quality control
  • BMP - Bitmap output
  • WebP - Lossy and lossless modes

Usage

image [options] <input-file> <output-file>

Common operations

Format conversion

Convert between formats by specifying different input and output extensions:
# Convert PNG to JPEG
image input.png output.jpg

# Convert JPEG to WebP
image input.jpg output.webp

# Convert any format to PNG
image input.gif output.png

Image transformations

Cropping

Crop image to specific rectangle:
image --crop <x>,<y>,<width>,<height> input.png output.png

Strip alpha channel

Remove transparency:
image --strip-alpha input.png output.png

Move alpha to RGB

Convert alpha channel to grayscale RGB:
image --move-alpha-to-rgb input.png output.png

CMYK operations

For CMYK images (typically from JPEG files):
# Invert CMYK values
image --invert-cmyk input.jpg output.jpg

Quality and compression

JPEG quality

image --quality 85 input.png output.jpg

PNG compression

image --compression-level 9 input.bmp output.png

WebP encoding

# Lossy WebP
image --quality 80 input.png output.webp

# Lossless WebP
image --lossless input.png output.webp

Frame extraction

Extract specific frame from animated images:
image --frame-index 0 animated.gif frame-0.png

Metadata operations

ICC profile handling

The utility preserves ICC color profiles when converting between formats that support them.

Implementation details

The image utility uses:
  • LibGfx: Core image decoding and encoding
  • ImageDecoder: Format-specific decoders
  • ImageWriter: Format-specific encoders (PNG, JPEG, BMP, WebP)
Source: ~/workspace/source/Utilities/image.cpp
The utility automatically detects the input format based on file content, not extension.
CMYK operations are only available for images with CMYK color space (typically JPEG files).
Some operations like cropping are not yet supported for CMYK bitmaps.

Build docs developers (and LLMs) love