Learn/Remade with Rust

rusty_image: BMP, ICO, TGA and QOI Codecs Remade in Rust

rusty_image 0.1.1 decodes and encodes BMP, ICO, TGA, PNM, HDR and QOI in pure Rust, pixel-identical to the image crate on 3,814 files. No C, no unsafe.

Signed by M·
A painted kitchen corkboard covered in small pinned pictures: app icons, a cursor arrow, a game texture swatch, a tiny landscape and a glowing sunset print
What is rusty_image and which formats does it cover?

rusty_image is a pure-Rust crate for the image formats that are not PNG or JPEG: BMP with clipboard DIBs, ICO/CUR, TGA, PNM/PAM, Radiance HDR and QOI, decode and encode. It also probes 13 formats from the header alone.

Talk about image parsing usually stops at PNG and JPEG. A real computer opens far more than that every day: the bitmap on the clipboard after a screenshot, the icon in a file manager, the cursor over a window, a TGA texture in a game folder, a PNM written by a lab instrument, an HDR environment map, a QOI frame from an indie engine. Those smaller formats mostly pass through stb_image, a single-header C library, or through the codecs bundled in Rust's image crate. rusty_image takes over that long tail in Rust.

The first public cut landed on 20 November 2026 as version 0.1.1, Apache-2.0, with forbid(unsafe_code) and no C. It reads and writes BMP, ICO/CUR, TGA, PNM/PAM, Radiance HDR and QOI, and its output matches image pixel for pixel on a 3,814-file generated corpus. Code sits under crates/rusty_image in the monorepo. Remade with Rust keeps a repo card for it, and MATA describes its use on this landing.

Trust is a pasted picture that never leaves the machine. Security is a decoder that cannot be talked past a header that lies. Incentive is speed: on most of the paths below, the Rust version is quicker than what it replaces.

Why the Formats PNG and JPEG Skip Still Matter

Small formats are small in popularity, not in risk. A BMP header declares width, height, bit depth and palette size. An ICO file is a directory of images, each with its own header. TGA has run-length packets. Every one of those numbers comes from whoever made the file, and a C decoder that trusts them can be walked off the end of a buffer. The NIST Secure Software Development Framework wants that kind of parser written in a memory-safe language, and CISA's memory safe roadmaps guidance names the same fix.

These files also arrive quietly. A paste counts as input. So does a downloaded icon pack. The Rails and ImageMagick upload bug showed what follows when a server hands an uploaded picture to a C toolchain it never chose. Moving this whole family of decoders into Rust gives the clipboard and the downloads folder the same protection as the photo library.

What rusty_image Decodes and Encodes

Every format here works in both directions. A tool that can read a TGA but has to call a C writer to save one has only half left the old stack.

Clipboard DIBs and BMP

BMP sits under the Windows clipboard. When someone copies a picture or takes a screenshot, apps often see a CF_DIB or CF_DIBV5 device-independent bitmap before anything reaches the disk. Both variants decode here, along with ordinary BMP files, including 8-bit palette images and 32-bit BMP. A paste handler built on this crate does not hand the clipboard to C.

Icons, Cursors, TGA, PNM, HDR and QOI

ICO and CUR cover application icons and mouse cursors. TGA, with or without run-length encoding, is still common in game asset folders. PNM and PAM are the plain portable formats many scientific and command-line tools emit. Radiance HDR stores high dynamic range images such as lighting maps. QOI, the Quite OK Image format, is a simple lossless format some engines use for fast saves. Each of the six has a decoder and an encoder.

Probing 13 Formats From the Header

Before a decode, a program often needs to know what it is holding. The crate can read the header of 13 formats and report what the file is without touching its pixels. An import step can check a file, or route it to the right codec, before it commits memory to the full decode. That is cheaper than a trial decode, and it keeps a mislabeled download away from the wrong parser.

How It Compares With the image Crate

Swapping a codec is only worth it if the output stays the same and the speed holds up. Ratios below are against image 0.25.10 on the ArtCraft team's harness, where above 1 means the Rust replacement is faster.

Pixel-Identical on 3,814 Files

The check is a generated corpus of 3,814 files across the supported formats, and every one matches image pixel for pixel. That matters more than any speed figure. A program that swaps its BMP or TGA decoder should never discover later that its icons shifted a shade.

Speed, Including Where It Trails

BMP-24 decode is 2.11× faster than image. TGA RLE decode is 2.06×. Radiance HDR encode is 3.12×, and BMP encode is 2.35–2.58×. QOI RGB decode climbed from 0.82× to 1.07× after the team traced the old deficit to op dispatch that compiled into a jump table mispredicting 59% of the time. QOI encode still trails, at 0.81× for RGB and 0.89× for RGBA, measured before the last two QOI changes. The November field note lists the instruction counts.

Pinning rusty_image Beside the Web Codecs

cargo add rusty_image fetches it. Web formats stay with rusty_png and rusty_jpeg. Archive scans go to rusty_tiff, and color profiles to rusty_icc. On a Home Computer, that set opens what people actually keep, from screenshots to photos they stopped renting. The EFF keeps documenting why local processing beats a hosted converter. Everything else in the family appears in MATA's rebuild catalog.

FAQ

Short answers already in this article.

Can rusty_image read a bitmap pasted from the Windows clipboard?

Yes. rusty_image decodes BMP including CF_DIB and CF_DIBV5 clipboard bitmaps, which is the shape a screenshot or a copied picture takes on the clipboard before an app saves it.

Does rusty_image produce the same pixels as the image crate?

rusty_image is pixel-identical to the image crate on a 3,814-file generated corpus, so a program can switch codecs without changing what it shows.

How fast is rusty_image compared with image 0.25.10?

rusty_image decodes BMP-24 2.11 times faster, decodes TGA RLE 2.06 times faster, encodes Radiance HDR 3.12 times faster and encodes BMP 2.35 to 2.58 times faster than image 0.25.10. QOI encode is still slower.

Where is rusty_image still slower than the image crate?

QOI encode, at 0.81 times the image crate's speed for RGB and 0.89 times for RGBA. Those figures were measured before the last two QOI changes in 0.1.1. QOI decode is now faster, at 1.07 times for RGB.

What does header-only probing in rusty_image do?

rusty_image can read the header of 13 formats and report what the file is without decoding its pixels. An upload or import step can check a file before it commits memory to a full decode.