libspng (simple png) 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, it outperforms the reference implementation in common use cases.
|Decode from stream|
|No known security bugs|
|Progressive image read|
|Parses all standard chunks|
|Doesn't require zlib|
 The project is fuzz tested on OSS-Fuzz and vulnerabilities are fixed before they become public.
 Building with miniz is supported.
 With a 3rd party patch
#include <spng.h> /* 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, code is also scanned with Clang Static Analyzer, Coverity Scan and PVS-Studio.
Releases follow the semantic versioning scheme with additional guarantees:
- Releases from 0.4.0 to 0.8.x are stable
- If 1.0.0 will introduce breaking changes then 0.8.x will be maintained as a separate stable branch
Currently 1.0.0 is planned to be compatible.
Online documentation is available at libspng.org/docs.
- Decoding to
SPNG_FMT_GA16output formats is not supported for all PNG color type and bit depth combinations, see documentation for details.
- Gamma correction is not implemented for
- Non-critical errors may cause an image to not load (#132).
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]