Rerun on 2026-10-23 (UTC): 1797 images, 1250.2 megapixels, on an AMD Ryzen 7 7735HS running Linux amd64. Every codec is single-threaded, pinned to CPU 2. Each image has one warmup and 3 measured repetitions; the reported encode and decode times are their separate medians. Codec order rotates between repetitions.
All codecs encode the same normalized 8-bit premultiplied pixels:
RGBA for libpng and stb, BGRA for BNG. RGB is premultiplied using
(channel * alpha + 127) / 255 with integer division.
Compression is lossless relative to those stored pixels, not the original PNG files:
premultiplication rounds colours and clears hidden RGB at zero alpha.
The one 16-bit source is reduced to its high byte; grayscale sources are expanded to RGBA.
libpng 1.6.55 uses zlib 1.3.1, compression level 6 and all adaptive row filters.
stb_image and stb_image_write use their defaults (PNG compression level 8,
automatic filtering). BNG uses the linked optimized implementation.
The harness was built with GCC 15.2.1, -O3 -DNDEBUG.
Source loading, normalization, premultiplication and verification are not timed.
BNG scratch/output buffers and libpng output/decode buffers are preallocated;
stb allocates internally inside its timed calls. libpng's internal allocations remain timed.
These are codec-call measurements, not end-to-end application timings.
Every codec's decoded pixels were compared byte for byte in every repetition, including warmups. PNG outputs were also cross-decoded with the other PNG decoder; BNG fast and reference encoders produced identical files, and both decoders matched. All 1797 source PNGs matched the downloadable corpus by SHA-256. There were no skipped images or pixel mismatches.
One source, screenshot_game/Htdamg_affinity.png, emitted an ancillary
iCCP: CRC error warning. It remained included, and both PNG decoders agreed on its pixels.
Overall, BNG is 13.13% smaller than libpng's output, with 29.61× faster encoding and 1.39× faster decoding on this corpus and machine. This is an aggregate comparison, not a guarantee for every image: 666 of the 1797 BNG files were larger than libpng's output.
In the tables, ms and KiB are means per image. MP/s is total pixels divided by the sum of per-image median times; bpp is total encoded bits divided by total pixels. Ratios are calculated from unrounded totals.
The full suite of test images can be downloaded here: bng_benchmark_suite.tar – 1797 PNG source files, ~1.0 GiB
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 8.86 | 131.63 | 78.51 | 5.29 | 610.1 | 7.184 |
| stb_image | 7.70 | 64.24 | 90.32 | 10.83 | 870.6 | 10.252 |
| bng | 6.38 | 4.45 | 108.99 | 156.50 | 530.0 | 6.241 |
1797 images, 1250.2 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 8.21 | 112.44 | 81.42 | 5.94 | 483.3 | 5.924 |
| stb_image | 7.25 | 57.64 | 92.19 | 11.59 | 684.3 | 8.388 |
| bng | 5.95 | 4.43 | 112.31 | 150.79 | 462.0 | 5.663 |
568 images, 379.6 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 22.51 | 259.54 | 83.28 | 7.22 | 1247.6 | 5.453 |
| stb_image | 17.12 | 149.87 | 109.47 | 12.51 | 1817.6 | 7.944 |
| bng | 15.04 | 9.25 | 124.58 | 202.57 | 1071.1 | 4.682 |
171 images, 320.5 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 24.60 | 562.35 | 58.53 | 2.56 | 2414.5 | 13.736 |
| stb_image | 25.88 | 213.46 | 55.64 | 6.75 | 3533.1 | 20.099 |
| bng | 18.41 | 15.05 | 78.21 | 95.66 | 1930.9 | 10.985 |
100 images, 144.0 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 81.20 | 453.39 | 100.07 | 17.92 | 2403.0 | 2.423 |
| stb_image | 44.89 | 436.72 | 181.01 | 18.61 | 3076.9 | 3.102 |
| bng | 48.76 | 22.08 | 166.63 | 367.94 | 1975.5 | 1.992 |
14 images, 113.8 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 4.18 | 89.95 | 72.66 | 3.38 | 421.1 | 11.357 |
| stb_image | 4.43 | 34.97 | 68.53 | 8.69 | 612.7 | 16.523 |
| bng | 3.63 | 2.64 | 83.58 | 115.12 | 406.3 | 10.957 |
235 images, 71.4 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 12.20 | 138.30 | 86.55 | 7.64 | 731.9 | 5.676 |
| stb_image | 8.98 | 81.33 | 117.69 | 12.99 | 1031.5 | 8.000 |
| bng | 8.40 | 5.24 | 125.69 | 201.46 | 609.8 | 4.729 |
59 images, 62.3 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 2.18 | 14.40 | 120.16 | 18.20 | 51.2 | 1.599 |
| stb_image | 1.27 | 11.80 | 206.56 | 22.22 | 68.8 | 2.150 |
| bng | 1.58 | 0.81 | 165.42 | 322.15 | 61.8 | 1.931 |
213 images, 55.8 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 18.38 | 413.33 | 59.00 | 2.62 | 2046.3 | 15.457 |
| stb_image | 19.81 | 164.66 | 54.74 | 6.59 | 2893.9 | 21.860 |
| bng | 14.80 | 11.34 | 73.29 | 95.66 | 1671.8 | 12.628 |
49 images, 53.1 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 16.60 | 303.32 | 63.15 | 3.46 | 1977.6 | 15.450 |
| stb_image | 17.36 | 133.39 | 60.41 | 7.86 | 2554.5 | 19.957 |
| bng | 12.58 | 8.97 | 83.34 | 116.94 | 1283.0 | 10.023 |
20 images, 21.0 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 1.78 | 29.48 | 73.18 | 4.41 | 163.7 | 10.324 |
| stb_image | 1.73 | 13.64 | 74.98 | 9.53 | 232.4 | 14.653 |
| bng | 1.41 | 0.95 | 92.35 | 137.37 | 144.2 | 9.095 |
113 images, 14.7 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 6.63 | 134.60 | 59.32 | 2.92 | 717.5 | 14.948 |
| stb_image | 7.44 | 56.92 | 52.86 | 6.91 | 979.4 | 20.404 |
| bng | 5.17 | 4.34 | 76.00 | 90.64 | 550.8 | 11.476 |
24 images, 9.4 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 2.25 | 20.96 | 90.59 | 9.73 | 223.8 | 8.993 |
| stb_image | 1.97 | 20.26 | 103.76 | 10.07 | 307.3 | 12.348 |
| bng | 2.00 | 0.95 | 101.92 | 214.27 | 201.5 | 8.097 |
18 images, 3.7 megapixels.
| decode ms | encode ms | decode MP/s | encode MP/s | size KiB | bpp | |
|---|---|---|---|---|---|---|
| libpng | 0.07 | 0.42 | 58.15 | 9.84 | 3.8 | 7.628 |
| stb_image | 0.05 | 0.34 | 86.88 | 12.00 | 4.4 | 8.896 |
| bng | 0.05 | 0.04 | 83.84 | 105.22 | 3.6 | 7.210 |
213 images, 0.9 megapixels.