Skip to main content

Decoding

Reading an image file into memory.

Header-only reads and full decodes, from bytes and from a file, on every corpus entry: synthetic images of four shapes and real photographs, each stored as png, jpg, bmp and tga. Speed is the best of 7 runs; memory is the extra peak RSS of one isolated process per measurement.

info: read the header only, no pixels

Width, height and channel count without decoding anything. Only libstb and Pillow have a header-only call; OpenCV and imageio do not, so they are absent here.

libstb is the reference (fastest on the most corpus entries). On average (E ⁣[tLtlibstb]\mathbb{E}\!\left[\dfrac{t_{L}}{t_{\text{libstb}}}\right], the mean of each entry's own ratio, not a ratio of medians): Pillow 6.4× as long.

Throughput vs. image size (higher is better)

Time vs. image size (lower is better)

decode: encoded bytes in, pixel array out

Each file was written by Pillow, never by stb. OpenCV has no TGA decoder, so it has no TGA entries. imageio delegates to Pillow, so it is Pillow plus its own overhead.

libstb is the reference (fastest on the most corpus entries). On average (E ⁣[tLtlibstb]\mathbb{E}\!\left[\dfrac{t_{L}}{t_{\text{libstb}}}\right], the mean of each entry's own ratio, not a ratio of medians): OpenCV 0.9×, Pillow 2.0×, imageio 3.3× as long.

libstb needs the least extra memory on the most entries (extra peak RSS on top of what the process held before the operation started; images under 0.065 MP are not measured). On average, E ⁣[mLmlibstb]\mathbb{E}\!\left[\dfrac{m_{L}}{m_{\text{libstb}}}\right]: OpenCV 4.2×, Pillow 5.1×, imageio 6.5× as much.

Throughput vs. image size (higher is better)

Time vs. image size (lower is better)

Extra peak memory vs. image size (lower is better)

load_file: path in, pixel array out

The same as decode but starting from a path, so file I/O is included: what someone actually types.

libstb is the reference (fastest on the most corpus entries). On average (E ⁣[tLtlibstb]\mathbb{E}\!\left[\dfrac{t_{L}}{t_{\text{libstb}}}\right], the mean of each entry's own ratio, not a ratio of medians): OpenCV 0.9×, Pillow 1.7×, imageio 2.7× as long.

libstb needs the least extra memory on the most entries (extra peak RSS on top of what the process held before the operation started; images under 0.065 MP are not measured). On average, E ⁣[mLmlibstb]\mathbb{E}\!\left[\dfrac{m_{L}}{m_{\text{libstb}}}\right]: OpenCV 4.2×, Pillow 4.9×, imageio 6.0× as much.

Throughput vs. image size (higher is better)

Time vs. image size (lower is better)

Extra peak memory vs. image size (lower is better)