Official libspng mirror
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitlab/issue_templates
docs
examples
src version bump to 0.4.1 Dec 2, 2018
tests
.gitignore
.gitlab-ci.yml
CMakeLists.txt
CONTRIBUTING.md
LICENSE
README.md
codecov.yml
meson.build
meson_options.txt

README.md

Overview

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.

Motivation

The goal is to provide a PNG library with a simpler API than libpng.

Peformance is also a priority, decoding is 8% faster than libpng for truecolor images with an alpha channel and 3% faster for truecolor images.

The testsuite is designed to test both libraries, it has already uncovered a bug in libpng.

Versioning

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

API/ABI changes can be tracked here.

Licensing

Code is licensed under the BSD 2-clause "Simplified" License.

The PngSuite and other images from libpng are used for regression testing.

Testing

libspng comes with an extensive test suite. There are over 700 test cases, 175 test images are decoded with all possible output format and flag combinations and compared against libpng's output. The testsuite also includes regression tests from libpng and is compiled with AddressSanitizer and UndefinedBehaviorSanitizer.

Security

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. Releases are scanned with Clang Static Analyzer and Coverity Scan and have a Defect Density of 0.00.

Documentation

Online documentation is available at https://libspng.org/doc.

Known Issues

  • spng_crc_set_action() is partially implemented, SPNG_CRC_DISCARD has no effect.

Building from source

Meson is the primary build system but CMake is also supported, the library only depends on zlib.

CMake build

mkdir -p cbuild
cd cbuild
cmake ..
make
make install

Meson build

meson build
cd build
ninja
ninja install

Running the testsuite

Only with Meson builds, the testsuite requires libpng.

# Run in build directory
meson configure -Ddev_build=true
ninja test

Benchmarking

# Run in source directory
git checkout tags/v0.4.1
wget https://gitlab.com/randy408/libspng/snippets/1786557/raw -O v041_opt.patch
git apply v041_opt.patch
git clone https://gitlab.com/randy408/benchmark_images.git
cd benchmark_images;
git checkout tags/v0.4.0
cd ../build
meson configure -Ddev_build=true -Dbuildtype=release -Db_pgo=generate
ninja benchmark
meson configure -Db_pgo=use
ninja benchmark
cat meson-logs/benchmarklog.txt