Project

pura-ico

0.0
The project is in a healthy, maintained state
A Ruby ICO/CUR decoder and ICO encoder using pura-png for PNG entries. Supports BMP and PNG icon entries, multiple bit depths, and multi-size ICO files.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 5.0
~> 13.0

Runtime

~> 0.1, >= 0.1.1
 Project Readme

pura-ico

A pure Ruby ICO decoder/encoder without additional image-processing libraries.

Part of the pura-* series — pure Ruby image codec gems.

Features

  • ICO decoding and encoding
  • Handles both BMP-style and PNG-style icon entries
  • Multiple icon sizes in a single file
  • Image resizing (bilinear / nearest-neighbor / fit / fill)
  • No image-specific native extension or FFI dependency
  • CLI tool included

Installation

gem install pura-ico

Usage

require "pura-ico"

# Decode (extracts the first/largest entry)
image = Pura::Ico.decode("favicon.ico")
image.width      #=> 32
image.height     #=> 32
image.pixels     #=> Raw RGB byte string
image.pixel_at(x, y) #=> [r, g, b]

# Encode
Pura::Ico.encode(images, "favicon.ico")

# Resize
thumb = image.resize(16, 16)

CLI

pura-ico decode favicon.ico --info

Why pure Ruby?

  • gem install and go — no brew install, no apt install, no C compiler needed
  • Both BMP and PNG entries — handles all common ICO formats
  • Part of pura-* — convert between JPEG, PNG, BMP, GIF, TIFF, WebP, ICO seamlessly

Related gems

Gem Format Status
pura-jpeg JPEG ✅ Available
pura-png PNG ✅ Available
pura-bmp BMP ✅ Available
pura-gif GIF ✅ Available
pura-tiff TIFF ✅ Available
pura-ico ICO ✅ Available
pura-webp WebP ✅ Available
pura-image All formats ✅ Available

Pixel model and limitations

Images contain 8-bit RGB pixels. Decoded pixels are RGB and do not retain transparency. CUR input can be decoded, but the encoder writes ICO only and has no CUR hotspot API.

crop(x, y, width, height) requires integer coordinates, positive dimensions, and a region entirely inside the image; invalid regions raise ArgumentError.

License

MIT