---
title: "Announcing heic-rs: a pure-Rust HEIC/HEIF decoder · heic-rs"
description: "Updated 2026-11-29 · By Thomas Braun, founder of Avarok Cybersecurity and creator of the Citadel Protocol heic-rs is a decoder for HEIC and HEIF images, the…"
canonical: "https://heic-rs.avarok.net/docs/announcing-0.1.5/"
lastmod: "2026-11-29T21:17:38Z"
tokens: 3611
---

1. [Docs](https://heic-rs.avarok.net/docs/)

# Announcing heic-rs: a pure-Rust HEIC/HEIF decoder

heic-rs@0.1.5·Updated 2026-11-29·8 min read·[View as markdown](https://heic-rs.avarok.net/docs/announcing-0.1.5/index.md)

*Updated 2026-11-29 · By [Thomas Braun](https://thomaspbraun.com/?utm_source=heic-rs-site\&utm_medium=social\&utm_campaign=heic-rs-0.1.5), founder of Avarok Cybersecurity and creator of the Citadel Protocol*

**heic-rs is a decoder for HEIC and HEIF images, the format iPhones and Macs save photographs in, written entirely in Rust: no C toolchain, no `unsafe`, `no_std`-friendly and wasm-ready, under MIT OR Apache-2.0.** On an Apple M3 Max it decodes a 2048×1536 HEIC stored as twelve tiles to RGB8 in 1.77 ms, against 7.58 ms for version 0.1.6 of the `heic` crate by imazen: 4.28× faster. Compiled to WebAssembly, it also decodes that image faster in a browser than libheif-js, and [heic-rs.avarok.net](https://heic-rs.avarok.net/) runs that comparison live, on your own device.

The crate has been on [crates.io](https://crates.io/crates/heic-rs) since 12 September 2026, and it passed 300,000 downloads before this, its first announcement (crates.io reported 339,918 on 29 November 2026). Version 0.1.5 shipped on 21 November. The source is at [github.com/tbraun96/heic-rs](https://github.com/tbraun96/heic-rs) and the API documentation is on [docs.rs](https://docs.rs/heic-rs).

## What is heic-rs?

heic-rs reads a HEIC or HEIF file and gives you pixels: RGB, RGBA, BGR, BGRA, grey or 16-bit. It implements both halves itself:

- **The container** (ISO/IEC 23008-12, HEIF): the ISOBMFF boxes, items and item properties, grid images assembled from tiles, rotation and mirroring, and EXIF and ICC extraction.
- **The codec** (ITU-T H.265, HEVC): a still-picture intra decoder covering CABAC, intra prediction, the inverse transforms, deblocking and SAO, for the Main, Main 10 and Main Still Picture profiles, 8 and 10 bits, in 4:2:0, 4:2:2, 4:4:4 and monochrome.

There is no `libheif`, no `libde265`, no `cmake` and no build script that shells out. The crate root says `#![forbid(unsafe_code)]`. With default features off it has zero dependencies and builds for `wasm32-unknown-unknown`, which CI checks on every push; with them on its one dependency is `rayon`.

## Why does it exist?

Before heic-rs, decoding HEIC in Rust meant one of two things:

- **`libheif-rs`**, bindings to the C library `libheif`. `libheif` is LGPL-3.0, the HEVC plugins usually shipped with it (`libde265`, `x265`) carry their own licences, and you need a C toolchain.
- **`heic` by imazen**, the other pure-Rust decoder, licensed AGPL-3.0. It is the decoder every benchmark below is measured against.

I needed a decoder under the ordinary Rust dual licence, MIT OR Apache-2.0, that builds with `cargo build` alone and runs in a browser. It was written for [CertifiedCopy](https://certified.sh/?utm_source=heic-rs-site\&utm_medium=social\&utm_campaign=heic-rs-0.1.5), which makes a verified copy of a phone on the user's own machine and has to show the phone's photographs in a browser. When heic-rs was started, Safari decoded HEIC and Chrome and Firefox did not. heic-rs is released on its own because it is useful on its own.

## How much faster is heic-rs than the heic crate?

Whole file in, RGB8 out, on the same four files with the same harness:

| file                | pixels    | tiles | heic-rs  | heic 0.1.6 | ratio | throughput (Mpx/s) |
| ------------------- | --------- | ----- | -------- | ---------- | ----- | ------------------ |
| `flat-64.heic`      | 64×64     | 1     | 0.023 ms | 0.025 ms   | 1.07× | 177 vs 165         |
| `gradient-512.heic` | 512×512   | 1     | 1.42 ms  | 2.30 ms    | 1.62× | 185 vs 114         |
| `checker-1024.heic` | 1024×1024 | 4     | 2.60 ms  | 4.94 ms    | 1.90× | 403 vs 212         |
| `photo-2048.heic`   | 2048×1536 | 12    | 1.77 ms  | 7.58 ms    | 4.28× | 1777 vs 415        |

Machine: Apple M3 Max (12 performance and 4 efficiency cores), macOS 27.0, 64 GB, rustc 1.98.0, release build. heic-rs ran on rayon's default pool, 16 threads here. `heic` 0.1.6 ran with `std` and its own `parallel` feature, the configuration its README recommends.

**Where the speed comes from.** Above 512 pixels on a side, macOS stores a HEIC as a grid of 512×512 tiles, and the tiles are independent coded pictures, so heic-rs decodes them at the same time. In the same harness, `photo-2048.heic` takes 17.00 ms on one thread and 1.83 ms on the pool (9.3×, twelve tiles); `checker-1024.heic` takes 9.76 ms and 2.67 ms (3.7×, four tiles). A single-tile image has nothing to spread and decodes at its serial speed.

The rest is serial work. That same twelve-tile picture took 23.8 ms on one thread before recent work on entropy decoding and reconstruction, and takes 17.0 ms now. Colour conversion, once the slow part of the crate, now expands chroma one row at a time and uses an integer fixed-point matrix within one least significant bit of the `f32` reference: 2048×1536 4:2:0 to RGB8 went from 21.97 ms to 2.240 ms on one thread, 9.8×.

Reading the container costs little: 1.47 µs for a thirteen-item file, so probing a directory of photographs for their sizes is cheap.

## How fast is it in a browser?

Compiled to WebAssembly with SIMD and run in a Web Worker in Chromium, heic-rs decodes `photo-2048.heic` in 24.2 ms against 34.7 ms for [libheif-js](https://www.npmjs.com/package/libheif-js) 1.23.5: libheif compiled to WebAssembly, and the most downloaded way to decode HEIC in a browser (5,360,107 npm downloads in the week of 22 to 28 November 2026). From a cold start, which downloads, compiles and starts the decoder and then decodes once, it is 43.0 ms against 88.1 ms, because heic-rs is 96 KB gzipped against 697 KB. On the 1-megapixel `checker-1024.heic` the warm margin is narrow, 4.4 against 4.8 ms. The two decode checker-1024 to identical pixels, and photo-2048 to within 51.8 dB PSNR of each other.

Built without wasm SIMD, heic-rs is slower warm than libheif-js on both files, so the site serves the SIMD build. Each figure is the median of nine runs, the decoders one at a time in random order, on the same Apple M3 Max; the raw results and the method are in [`bench/browser/`](https://github.com/tbraun96/heic-rs/tree/HEAD/bench/browser).

[heic-rs.avarok.net](https://heic-rs.avarok.net/) shows a HEIC that heic-rs decodes in your browser as the page loads, and its **Live speed demo** decodes the same file with libheif-js and heic-rs on your device, one at a time, showing download + start-up and decode times as they arrive.

## How was it measured?

The two decoders run alternately in the same process. Each measurement is one discarded warm-up, then the best of nine; the alternating cycle is repeated and the lowest run is reported, so background load on the machine hits both decoders equally. heic-rs's column comes from `examples/throughput.rs`, which takes a directory of HEICs, so the same harness can be pointed at either decoder. Every number above is in [`benches/results.json`](https://github.com/tbraun96/heic-rs/blob/HEAD/benches/results.json), and a script redraws the README's charts from it and fails if the README's tables stop agreeing with it. To reproduce on your own files:

```
cargo run --release --example throughput -- path/to/a/directory/of/heics
```

## What do these benchmarks not prove?

- **The corpus is four synthetic files.** They are PNGs generated by a script in the repository and encoded to HEIC with Apple's `sips`. `photo-2048.heic` is photograph-like content, not a photograph from a camera. Your files will differ; measure them.
- **One machine.** All numbers are from one Apple M3 Max, natively and in Chromium. Nothing here was measured on x86, on a phone, or in Safari or Firefox; the live demo is how to see your own.
- **No like-for-like single-thread comparison.** heic-rs's serial figure (17.0 ms for `photo-2048.heic`) is slower than `heic` running with its own parallel feature (7.58 ms). In wasm, where there are no threads, heic-rs runs at its serial speed. I have not measured `heic` on one thread, so there is no serial ratio to quote.
- **The small-file margin is thin.** On `flat-64.heic`, 0.023 against 0.025 ms is one file and a difference of about two microseconds.
- **The common iPhone shape is not in the table.** 4032×3024 arrives as 8 columns by 6 rows of tiles; it is covered by the correctness and colour benchmarks, not the head-to-head decode table.

## Does it decode correctly?

heic-rs measures itself against Apple's own decoder, not against another Rust crate. The fixtures are encoded with `sips -s format heic`, and the reference is what `sips` decodes them back to. Where a fixture's chroma is constant, such as a solid colour or an achromatic checkerboard, the output is asserted bit for bit, including a 2×2 grid. Elsewhere the tests assert at least 45 dB PSNR on RGB and 55 dB on luma; the measured figures are about 48 dB and 60 dB. A rotated fixture is compared against Apple's rotated output, so skipping the rotation fails the test.

## How was it written?

heic-rs is an independent implementation of ISO/IEC 23008-12 (HEIF) and of the decoding process in ITU-T H.265 | ISO/IEC 23008-2 (HEVC), written from the published specification text. No code was taken from any GPL, LGPL or AGPL licensed decoder. Two permissively licensed Rust projects, `rust_h265` and `scuffle-h265` (both MIT OR Apache-2.0), were consulted to cross-check header syntax only, with no code copied. The repository's [NOTICE](https://github.com/tbraun96/heic-rs/blob/HEAD/NOTICE) records this. The licence grants no patent rights in the HEVC standard itself; that question concerns the codec, and it is the same for every HEVC decoder.

## Is it safe to decode untrusted files?

That is the case it was built for. Library code contains no `unsafe`, `unwrap`, `expect` or `panic!`, every parser is bounds-checked, and `DecodeOptions::max_pixels` (256 megapixels by default) caps the allocation before it happens. Three fuzz targets (`decode`, `probe`, `boxes`) run in CI on every push. Versions 0.1.2 to 0.1.4 fixed what fuzzing and outside reports found: a panic on a malformed `uuid` box, a resource-exhaustion bug in which a 690-byte file asked for 2.2 GB, and five ways a malformed HEVC stream could panic (three in release builds, two only with overflow checks on). None had memory-safety impact, because the crate forbids `unsafe`. If you decode uploads, use 0.1.4 or later.

## What is new in 0.1.5?

Camera and phone files that decoded wrongly or not at all, all fixed by outside contributors:

- **4:2:2 pictures** (Canon and Sony `.HIF`) now decode; pictures from a Sony a7 IV match FFmpeg sample for sample.
- **4:4:4 pictures** with 4×4 transform blocks no longer lose sync.
- **Colour declared on the tiles** rather than the grid (Canon; a OnePlus 11's Display P3 profile) is now used, as is colour declared only in the HEVC bitstream.
- **New API**: `images`, `decode_image` and `probe_image` reach every displayable image in a file, not only the primary one.

Thank you to Johann Woelper, jaredt17, HeviLUO, Sidney Markowitz, Akos Arinton and JINGHAN YU for 0.1.5, and to s17sh70x2jfl031ag for the fuzzing reports behind 0.1.4. The full list is in the [changelog](https://github.com/tbraun96/heic-rs/blob/HEAD/CHANGELOG.md).

## What does it not do?

It does not decode AVIF (the error names AVIF explicitly), does not encode, and does not decode image sequences, animation, `iovl` overlays, inter-predicted pictures or the HEVC range extensions. Anything it cannot decode comes back as `Error::Unsupported` naming the missing tool, never as wrong pixels. Alpha decoding end to end and portable SIMD for colour conversion are on the roadmap.

## How do I use it?

```
cargo add heic-rs
```

```rust
use heic_rs::{decode, DecodeOptions, PixelLayout};

let bytes = std::fs::read("photo.heic")?;
let options = DecodeOptions { layout: PixelLayout::Rgba8, ..DecodeOptions::default() };
match decode(&bytes, &options) {
    Ok(image) => println!("{}x{} -> {} bytes", image.width, image.height, image.data.len()),
    Err(e) => eprintln!("decode failed: {e}"),
}
```

For `no_std` or the browser, turn default features off:

```toml
heic-rs = { version = "0.1", default-features = false }
```

It is free and open source under MIT OR Apache-2.0, at your option.

## Who builds it?

heic-rs is a project of [Avarok](https://avarok.net/?utm_source=heic-rs-site\&utm_medium=social\&utm_campaign=heic-rs-0.1.5), which builds security software in Rust. Avarok's main product is [Citadel Workspace](https://work.avarok.net/?utm_source=heic-rs-site\&utm_medium=social\&utm_campaign=heic-rs-0.1.5), a post-quantum, peer-to-peer collaborative workspace built on the Citadel Protocol; heic-rs is not part of it, but comes from the same habit of writing the dependency in Rust when no suitable one exists.

If heic-rs is useful to you, a star on [the repository](https://github.com/tbraun96/heic-rs) helps other people find it, and bug reports with a sample file are the most useful contribution of all. I post about releases at [x.com/tbraun96](https://x.com/tbraun96).

```json
{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@id": "https://thomaspbraun.com/#person",
      "@type": "Person",
      "name": "Thomas Braun",
      "sameAs": [
        "https://github.com/tbraun96",
        "https://x.com/tbraun96"
      ],
      "url": "https://thomaspbraun.com",
      "worksFor": {
        "@type": "Organization",
        "name": "Avarok",
        "url": "https://avarok.net"
      }
    },
    {
      "@id": "https://heic-rs.avarok.net/docs/announcing-0.1.5/",
      "@type": "WebPage",
      "author": {
        "@id": "https://thomaspbraun.com/#person"
      },
      "dateModified": "2026-11-29T21:17:38Z",
      "description": "Updated 2026-11-29 · By Thomas Braun, founder of Avarok Cybersecurity and creator of the Citadel Protocol heic-rs is a decoder for HEIC and HEIF images, the…",
      "inLanguage": "en",
      "isPartOf": {
        "@id": "https://heic-rs.avarok.net/#website",
        "@type": "WebSite",
        "name": "heic-rs",
        "url": "https://heic-rs.avarok.net/"
      },
      "name": "Announcing heic-rs: a pure-Rust HEIC/HEIF decoder · heic-rs",
      "url": "https://heic-rs.avarok.net/docs/announcing-0.1.5/"
    }
  ]
}
```
