randy408/libspng logo

randy408/libspng

Free

Simple, modern libpng alternative

FreeFree tier
Type
Open Source

About randy408/libspng

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. It is designed as a simpler, faster alternative to libpng, featuring a clean API, comprehensive fuzz testing, and support for all standard PNG chunks. The library outperforms the reference implementation in common use cases and is written according to the CERT C Coding Standard with integer overflow checks. It does not require zlib (miniz is supported) and is continuously fuzzed on OSS-Fuzz. Encoding and decoding are supported, with animated PNG planned for a future release. Licensed under BSD 2-clause.

Key Features

Decode PNG from stream
Gamma correction
Progressive image read
Parses all standard chunks
Encoding support
No zlib dependency (can use miniz)
Fuzz tested on OSS-Fuzz
Simple API compared to libpng
Integer overflow checks and memory safety

Pros & Cons

Pros
  • Simpler API compared to libpng
  • Outperforms libpng in common use cases
  • Security-focused: fuzz tested, CERT C compliant, no known security bugs
  • Supports all standard PNG chunks
  • Does not require zlib (optional miniz)
Cons
  • Animated PNG support only planned, not yet implemented
  • API not compatible with libpng, requires code migration
  • Relatively new library with smaller community

Best For

Reading PNG image files in applicationsWriting PNG image filesEmbedded systems requiring a lightweight PNG librarySecurity-critical applications needing a fuzzed libraryImage processing pipelines

FAQ

What is libspng?
libspng is a C library for reading and writing PNG files, designed as a simpler and more secure alternative to libpng.
How does libspng compare to libpng?
libspng offers a simpler API, better performance in common use cases, and enhanced security through fuzz testing and coding standards.
Is libspng safe to use?
Yes, the library is continuously fuzzed on OSS-Fuzz, follows the CERT C Coding Standard, and handles all errors gracefully.
Does libspng require zlib?
No, building with miniz is supported as an alternative.