Field notes/Mediarusty_imageBMPQOI

rusty_image: BMP, TGA, HDR and QOI in Pure Rust

rusty_image decodes and encodes BMP, ICO/CUR, TGA, PNM/PAM, Radiance HDR and QOI in pure Rust, pixel-identical to the image crate, and decodes 24-bit BMP 2.11x faster.

Signed by M·
Painted wooden clipboard holding small pictures of many shapes in a sunlit studio
What is rusty_image?

rusty_image is a pure-Rust crate from Remade with Rust that decodes and encodes BMP (including CF_DIB and CF_DIBV5 clipboard bitmaps), ICO and CUR, TGA, PNM and PAM, Radiance HDR and QOI, and probes the headers of 13 image formats without decoding them. It is Apache-2.0, has no C and no unsafe code, and version 0.1.1 is on crates.io.

Ship it

2.11× Faster BMP Decode

than the image crate on 24-bit BMP, with pixels identical across a 3,814-file corpus.

Open the rusty_image conversion pin →

rusty_image is a pure-Rust decoder and encoder for BMP, ICO and CUR, TGA, PNM and PAM, Radiance HDR and QOI. Version 0.1.1 is pixel-identical to the image crate on a 3,814-file generated corpus and decodes 24-bit BMP 2.11 times faster than image 0.25.10. It is Apache-2.0, with no C and no unsafe.

These are the small formats that turn up everywhere: icons, cursors, game textures, screenshots, HDR environment maps, and the bitmap Windows puts on the clipboard when you copy a picture. Each one is a parser that runs on files the user did not make. rusty_image gives the Remade with Rust stills lane one memory-safe crate for all of them.

Source, the Cargo line and release links are on the rusty_image repo landing. The campaign that produced the current speed figures has its own write-up covering TIFF, image and ICC.

What rusty_image Covers

Six formats, both directions

The rusty_image crate decodes and encodes BMP, ICO and CUR, TGA, PNM and PAM, Radiance HDR and QOI. Header-only probing reports the format, size and pixel layout of 13 image formats without decoding the pixels, which is what an upload form or file browser needs before it commits memory to a picture.

What each format is for

BMP is the uncompressed Windows bitmap, still the shape of screenshots and clipboard pictures. ICO and CUR hold icons and cursors, several sizes in one file. TGA is an old format that game and 3D tools still use for textures, often with run-length compression. PNM and PAM are the plain Netpbm formats that image tools pass between each other. Radiance HDR stores high dynamic range light values in floating point, which is how environment maps for 3D lighting are shipped. QOI is a newer lossless format designed to be simple and fast to encode and decode. None of them is glamorous, and all of them arrive in files the user did not make, so each one is a parser on hostile input. rusty_image puts them behind one memory-safe crate instead of six C code paths.

Clipboard bitmaps

When a Windows user copies an image, the clipboard holds a CF_DIB or CF_DIBV5: a BMP without its file header. A Rust app that supports paste has to decode that shape. rusty_image reads both variants, so paste works without pulling in a C imaging library.

Pixel-identical by test

Moving a decoder should not move a pixel. rusty_image was checked against the image crate on a generated corpus of 3,814 files across every format and layout it supports, and the outputs match. Its code lives under crates/rusty_image in the remade_ffmpeg_rs monorepo, with releases on crates.io.

Measured Speed in 0.1.1

Ahead of the image crate

On pinned, interleaved (ABBA) runs, N=20, on the ArtCraft team's harness, against image 0.25.10: 24-bit BMP decode is 2.11 times faster, TGA RLE decode 2.06 times, Radiance HDR encode 3.12 times, and BMP encode 2.35 to 2.58 times. QOI RGB decode moved from 0.82 times to 1.07 times during the campaign. The decoder's per-op dispatch had compiled to a jump table that mispredicted 59 percent of the time, and fixing that is what turned the result around.

Where it still trails

QOI encode is behind image, at 0.81 times for RGB and 0.89 times for RGBA. Those numbers were taken before the last two QOI changes landed, so the current gap may be smaller, but it has not been re-measured. Under callgrind on 1536 by 1024 crops of a real photo, QOI encode retires 30 percent fewer instructions than 0.1.0 for RGB and 45 percent fewer for RGBA, and QOI decode 38 and 35 percent fewer. On BMP, the 8-bit palette path retires 37 percent fewer instructions and the 32-bit path 33 percent fewer. Every output is byte-identical to 0.1.0.

Who should adopt it first

Desktop apps that paste images, games and tools that load TGA, ICO or HDR assets, and upload services that probe a file before accepting it. Anyone who already uses image for these formats can compare outputs file by file, because they are meant to be the same.

How rusty_image Fits the Constellation

Inside Media

rusty_image covers the formats that rusty_jpeg, rusty_png, rusty_gif and rusty_dds do not. rusty_tiff takes scans and archives, and rusty_icc converts colour when a file carries a profile. Together with remade_ffmpeg_rs they make a stills stack with no C decoder in it.

Across clusters

Decoded pixels feed Mind engines such as Carmenta for OCR, land in SpaceDB as thumbnails, and pass a Deputy audit before a binary is placed on hardware nobody babysits.

The API and its guard rails

probe returns the format, width and height from the header alone, decode returns an Image with rows top to bottom and no padding, and encode writes any of the supported formats. Clipboard work goes through bmp::decode_dib and bmp::encode_dib with a DibKind, and ico::decode_entries yields every icon size along with cursor hotspots. The README reports more than 17,000 truncated and bit-flipped copies decoded without a panic, and a header claiming more than 1 GiB of pixels, or a BMP side past 65,535, is refused before anything is allocated. An upload handler on MATA.NETWORK can call probe first and reject oversize files for free. For the reasoning behind rebuilding these parsers at all, read The Importance of Remade With Rust and the NIST SSDF memory-safety guidance.

FAQ

Quick answers for builders evaluating this technology.

What does rusty_image replace?

It replaces the BMP, ICO, TGA, PNM, HDR and QOI codecs in the image crate, and stb_image for those formats. Its output is pixel-identical to the image crate on a generated corpus of 3,814 files.

How fast is rusty_image compared with the image crate?

Against image 0.25.10 on pinned, interleaved runs, 24-bit BMP decode is 2.11 times faster, TGA RLE decode 2.06 times, Radiance HDR encode 3.12 times and BMP encode 2.35 to 2.58 times. QOI RGB decode is 1.07 times as fast.

Is rusty_image faster everywhere?

No. QOI encode still trails the image crate, at 0.81 times its speed for RGB and 0.89 times for RGBA. Those two numbers were measured before the last two QOI changes in 0.1.1.

Why does rusty_image read clipboard bitmaps?

Windows puts copied pictures on the clipboard as CF_DIB or CF_DIBV5, a BMP without its file header. Paste into a Rust app means decoding that format, and rusty_image reads both variants.

Where is the rusty_image source?

rusty_image lives in the remade_ffmpeg_rs monorepo under crates/rusty_image on GitHub. Add it with cargo add rusty_image.