icontool

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2025 License: MIT Imports: 13 Imported by: 0

README

icontool

A simple CLI tool for creating icon files from images in Go.

Features

  • Create Windows .ico files from one or more PNG/JPEG/GIF images
  • Create macOS .icns files from square PNG/JPEG/GIF images
  • Generate C header files with embedded icon data for GLFW/SDL applications
  • Support for multiple image sizes in a single icon file
  • Automatic image sorting by size
  • Glob pattern support for batch processing

Installation

Install directly with Go:

go install github.com/adnsv/icontool@latest

Or build from source:

git clone https://github.com/adnsv/icontool.git
cd icontool
go build

Usage

The tool automatically determines the output format from the file extension.

Create a Windows .ico file
# From specific files
icontool -o app.ico icon-16.png icon-32.png icon-48.png icon-256.png

# Using glob patterns
icontool -o app.ico icons/icon-*.png

# Single image
icontool -o icon.ico icon.png
Create a macOS .icns file
# From specific files (must be square images)
icontool -o app.icns icon-16.png icon-32.png icon-128.png icon-256.png icon-512.png

# Using glob patterns
icontool -o app.icns icons/icon-*.png

# Recommended sizes: 16, 32, 64, 128, 256, 512, 1024
icontool -o app.icns icon-{16,32,64,128,256,512,1024}.png
Create a C header with embedded icon data
# Basic usage
icontool -o icon.h icon-32.png icon-64.png

# Custom function name
icontool -o icon_data.h -func setup_app_icon icon.png

# Works with .c, .h, .hpp, .cpp extensions
icontool -o icon_data.hpp icon.png

Options

  • -o, --output <file> - Output file path (required)
  • -func <name> - Function name for C/C++ headers (default: setup_window_icon)

Supported Output Formats

The output format is automatically determined by the file extension:

  • .ico - Windows icon file
  • .icns - macOS icon file (requires square images)
  • .h, .c, .hpp, .cpp - C/C++ header with embedded icon data

Supported Image Formats

  • PNG
  • JPEG
  • GIF

How It Works

  1. Image Loading: Loads and decodes image files using Go's standard image library
  2. Sorting: Automatically sorts images by size (smallest to largest)
  3. Format Conversion: Converts images to appropriate formats (PNG for .ico, RGBA for C headers)
  4. Output Generation: Creates properly formatted output files
.ico Format

The tool creates standard Windows .ico files with:

  • Proper ICONDIR and ICONDIRENTRY headers
  • PNG-encoded image data
  • Support for multiple resolutions in a single file
  • Sizes up to 256x256 pixels
.icns Format

The tool creates macOS .icns files with:

  • Standard ICNS container format
  • PNG-encoded image data for all icon elements
  • Support for Retina (@2x) variants
  • Supported sizes: 16x16, 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024
  • Proper OSType codes (icp4, icp5, ic07, ic08, ic09, ic10, ic11, ic12, ic13, ic14)
  • Only square images are used (non-square images are skipped)
C Header Format

Generated C headers include:

  • Static const arrays with RGBA pixel data
  • One array per input image
  • Placeholder setup function
  • Include guards

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL