libspng is a C library for reading and writing Portable Network Graphics (PNG) format files with a focus on security and ease of use.
libspng is an alternative to libpng, the projects are separate and the APIs are not compatible.
The goal is to provide a fast PNG library with a simpler API than libpng.
|Decode to RGBA8/16||✓||✓||✓||✓|
|Decode from stream||✓||✓||✓|
|Fuzzed by OSS-Fuzz||✓||✓||✓|
|Doesn't require zlib||✓||✓|
* Feature in planning phase
** With a 3rd party patch
/* Create a context */ spng_ctx *ctx = spng_ctx_new(0); /* Set an input buffer */ spng_set_png_buffer(ctx, buf, buf_size); /* Determine output image size */ spng_decoded_image_size(ctx, SPNG_FMT_RGBA8, &out_size); /* Decode to 8-bit RGBA */ spng_decode_image(ctx, out, out_size, SPNG_FMT_RGBA8, 0); /* Free context memory */ spng_ctx_free(ctx);
Code is licensed under the BSD 2-clause "Simplified" License.
The project contains optimizations and test images from libpng, these are licensed under the PNG Reference Library License version 2.
Security & Testing
Code is written according to the rules of the CERT C Coding Standard. All integer arithmetic is checked for overflow and all error conditions are handled gracefully.
The library is continuously fuzzed by OSS-Fuzz, releases are scanned with Clang Static Analyzer, PVS-Studio, and Coverity Scan.
The test suite consists of over 700 test cases, 175 test images are decoded with all possible output format and flag combinations and compared against libpng for correctness.
Releases follow the semantic versioning scheme with a few exceptions:
- Releases from 0.4.0 to 0.8.x are stable
- 0.8.x will be maintained as a separate release branch from 1.0.0
Note that 1.0.0 will introduce little to no breaking changes.
Online documentation is available at libspng.org/docs.
- Text and iCCP chunks are not read.
spng_crc_set_action()is partially implemented,
SPNG_CRC_DISCARDhas no effect.