Benchmark results on 1797 different images

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

Total

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng8.86131.6378.515.29610.17.184
stb_image7.7064.2490.3210.83870.610.252
bng6.384.45108.99156.50530.06.241

1797 images, 1250.2 megapixels.

screenshot_game

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng8.21112.4481.425.94483.35.924
stb_image7.2557.6492.1911.59684.38.388
bng5.954.43112.31150.79462.05.663

568 images, 379.6 megapixels.

pngimg

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng22.51259.5483.287.221247.65.453
stb_image17.12149.87109.4712.511817.67.944
bng15.049.25124.58202.571071.14.682

171 images, 320.5 megapixels.

photo_tecnick

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng24.60562.3558.532.562414.513.736
stb_image25.88213.4655.646.753533.120.099
bng18.4115.0578.2195.661930.910.985

100 images, 144.0 megapixels.

screenshot_web

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng81.20453.39100.0717.922403.02.423
stb_image44.89436.72181.0118.613076.93.102
bng48.7622.08166.63367.941975.51.992

14 images, 113.8 megapixels.

textures_pk02

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng4.1889.9572.663.38421.111.357
stb_image4.4334.9768.538.69612.716.523
bng3.632.6483.58115.12406.310.957

235 images, 71.4 megapixels.

textures_plants

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng12.20138.3086.557.64731.95.676
stb_image8.9881.33117.6912.991031.58.000
bng8.405.24125.69201.46609.84.729

59 images, 62.3 megapixels.

icon_512

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng2.1814.40120.1618.2051.21.599
stb_image1.2711.80206.5622.2268.82.150
bng1.580.81165.42322.1561.81.931

213 images, 55.8 megapixels.

photo_wikipedia

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng18.38413.3359.002.622046.315.457
stb_image19.81164.6654.746.592893.921.860
bng14.8011.3473.2995.661671.812.628

49 images, 53.1 megapixels.

textures_photo

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng16.60303.3263.153.461977.615.450
stb_image17.36133.3960.417.862554.519.957
bng12.588.9783.34116.941283.010.023

20 images, 21.0 megapixels.

textures_pk01

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng1.7829.4873.184.41163.710.324
stb_image1.7313.6474.989.53232.414.653
bng1.410.9592.35137.37144.29.095

113 images, 14.7 megapixels.

photo_kodak

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng6.63134.6059.322.92717.514.948
stb_image7.4456.9252.866.91979.420.404
bng5.174.3476.0090.64550.811.476

24 images, 9.4 megapixels.

textures_pk

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng2.2520.9690.599.73223.88.993
stb_image1.9720.26103.7610.07307.312.348
bng2.000.95101.92214.27201.58.097

18 images, 3.7 megapixels.

icon_64

decode msencode msdecode MP/sencode MP/ssize KiBbpp
libpng0.070.4258.159.843.87.628
stb_image0.050.3486.8812.004.48.896
bng0.050.0483.84105.223.67.210

213 images, 0.9 megapixels.