libpng 1.8.0.git for C PNG Encoding and Decoding
LIBPNG: Portable Network Graphics support, official libpng repository
At a glance
- What is it?
- libpng is a C library for reading and writing PNG data, with separate I/O, transformation, metadata, error handling, and progressive-reading modules. It fits applications that need direct control over PNG processing, but its public API and zlib dependency require deliberate integration.
- Who is it for?
- libpng is appropriate for C programs that need direct PNG encoding or decoding, incremental input handling, or access to image metadata through public APIs. It is a poor fit for a quick image conversion utility unless the application can absorb its C API and zlib dependency.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly C, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.
Editorial analysis
Why libpng Serves Native C Image Pipelines
libpng addresses the part of an application that must interpret or produce PNG images without implementing the format itself. It is aimed at developers embedding PNG support in C software, particularly code that needs control over streams, decoded rows, transformations, metadata, errors, or memory. The repository includes reading, writing, metadata, memory management, and error-handling code, so the library covers more than basic file conversion.
The format choice has a direct consequence: libpng is not a standalone command-line image editor. A native program supplies streams or buffers and calls the library's interfaces. The README points new users to `example.c` and `pngtest.c` for usage examples, while `libpng-manual.txt` contains the detailed API guide. This separation makes libpng useful as an embedded component rather than an end-user application.
It is also designed for input that does not fit a simple whole-file model. The README documents support for reading a stream after some signature bytes have already been consumed. That matters for protocols and containers that pass PNG data in pieces, or embed a PNG image without its normal file signature. Progressive reading is represented by `pngpread.c`, giving applications a path for PNG data that becomes available incrementally.
libpng's Read and Write Pipeline
The repository layout exposes a staged design. For input, `pngrio.c` contains the lowest-level read operations, `pngread.c` provides high-level reading, `pngrtran.c` applies transformations to image data, and `pngrutil.c` supplies reading utilities. Metadata access is divided between `pngget.c` and `pngset.c`. Memory ownership and allocation behavior are handled in `pngmem.c`, while `pngerror.c` centralizes warning and error message I/O.
The output side has a parallel organization. `pngwio.c` provides low-level write I/O, `pngwrite.c` exposes higher-level writing operations, `pngwtran.c` handles write transformations, and `pngwutil.c` provides supporting utilities. This separation is useful when diagnosing an integration because it gives each stage a distinct source file rather than placing all PNG behavior in one entry point.
Private declarations are kept in headers such as `pngpriv.h`, `pngstruct.h`, `pnginfo.h`, `pngdebug.h`, and `pngtarget.h`. The public surface is centered on `png.h`, with system-specific configuration exposed through `pngconf.h`. Since libpng 1.5.0, the definitions of `png_struct` and `png_info` have moved into private headers inaccessible to applications. Applications should use the `png_set_<chunk>` and `png_get_<chunk>` functions instead of directly modifying the internal structures. That restriction is deliberate: it reduces coupling to implementation details, but it also means older programs that accessed those structures must be converted.
Installing libpng and Starting With Its Examples
The README directs installation instructions to `INSTALL`. The repository entries available on GitHub do not include that file, so the exact configure command, build command, installation prefix, and platform-specific prerequisites cannot be reproduced without guessing. For that reason, this tutorial does not invent a shell command.
The repository does confirm the available build inputs. It contains `CMakeLists.txt`, `Makefile.am`, `configure.ac`, `autogen.sh`, `ci`, and architecture-specific directories including `arm`, `intel`, `loongarch`, and `mips`. The README also distinguishes distribution archives by line-ending convention, but it does not give a complete command sequence for any one archive.
A first integration should start from the repository's documented examples, not an improvised API call. `example.c` is identified as an example of libpng functions in a program, and `pngtest.c` is the library test program with `pngtest.png` as its sample image. The detailed behavior and required arguments for these programs are not shown in the README. Before building them, consult `INSTALL`, `example.c`, and `pngtest.c` together. This also lets the reader confirm how the local zlib installation is discovered and which build configuration is appropriate.
zlib Compatibility and Compression Constraints
PNG compression is delegated to zlib. The README says zlib 1.0.4 or later should be used, while warning that libpng may work with versions as old as zlib 0.95. That fallback is not presented as an equally sound target. The documentation specifically says older zlib versions contain bugs that can produce invalid compression streams for some images.
This makes the compression dependency part of PNG correctness rather than a packaging detail. A build that links successfully can still encounter malformed compressed output if it uses an unsupported old zlib. The project directs users to zlib documentation for compression behavior and restrictions, and it also points to zlib.net as a source for the library.
The alternative here is not another PNG decoder but the use of zlib itself for a narrower job. zlib performs general-purpose compression, including compression beyond PNG files, whereas libpng interprets PNG structures, chunks, metadata, image rows, transformations, and application-facing read or write operations. Choosing zlib directly can be appropriate when the real requirement is compressed data rather than PNG encoding or decoding. Choosing libpng makes sense when the container semantics and image representation are the primary task.
ABI Changes, API Migration, and Upgrade Work
libpng has a long history, but that history includes compatibility consequences. The README notes that changes to `png_info` made an early release binary-incompatible with libpng 0.89 and earlier when using a shared library. It also records a change to the `filler` parameter type for `png_set_filler()` from `png_byte` to `png_uint_32`, which can affect shared-library applications.
The broader migration is more important for current integration. Direct application access to `info_ptr` was discouraged after new metadata APIs appeared in 0.95. Transitional releases allowed it with deprecation warnings, but libpng 1.5.0 ended that access and moved the structure definitions into private headers. Programs carried forward from older releases may therefore require source changes even when their image-processing behavior appears unchanged.
Upgrade planning should account for both compilation and runtime contracts. The repository contains `CHANGES`, `ANNOUNCE.md`, and `TODO.md`, while `png.h` is the documented location for usage restrictions and the version note. The README does not state a semantic-version compatibility policy for the `libpng18` default branch, so it would be incorrect to promise drop-in upgrades. The project has no GitHub releases listed, which means release tracking may need to rely on repository files and the project's own distribution channels.
Maintenance Signals, Distribution, and License Review
The repository is not archived, and its last push was on 2026-10-12. That is a current maintenance signal, but it does not establish a release cadence or compatibility promise. There are no GitHub releases associated with the repository, while the README identifies `libpng-*.tar.gz`, `libpng-*.tar.xz`, `lpng*.7z`, and `lpng*.zip` as distribution formats. It also points to download locations on SourceForge and `libpng.download`.
Source selection matters because the README identifies the checkout as `1.8.0.git`, while the default branch is named `libpng18`. A build intended for distribution should be tied to a known source state rather than assuming that a branch name alone identifies a stable release. `CHANGES`, `ANNOUNCE.md`, and the note near the top of `png.h` are the first repository files to inspect for that purpose.
The repository declares a custom license under `LICENSE.md`, which GitHub cannot classify using its standard license categories. The README says that file covers use and redistribution. It also includes `TRADEMARK.md` and a `LICENSES` directory, so an application distributor needs to inspect those files alongside the library license. This review concerns repository obligations only and is not a legal determination about a particular product or distribution model.
Editorial conclusion
libpng is appropriate for C programs that need direct PNG encoding or decoding, incremental input handling, or access to image metadata through public APIs. It is a poor fit for a quick image conversion utility unless the application can absorb its C API and zlib dependency. Before adoption, verify the instructions in `INSTALL`, confirm compatibility with the bundled configuration, and check `LICENSE.md` for the project's redistribution terms.
Frequently asked questions
Which zlib version should I use with libpng 1.8.0.git?
The README says to use zlib 1.0.4 or later. Although older versions as far back as 0.95 may work, the documentation warns that bugs in those versions can cause invalid compression streams for some images.
Where can I find libpng installation instructions and C examples?
The README points installation users to `INSTALL` and recommends `libpng-manual.txt`, `example.c`, and `pngtest.c` for API documentation and examples. `pngtest.png` is the repository's sample image for `pngtest.c`.
Can an application access libpng's png_struct or png_info fields directly?
Since libpng 1.5.0, direct application access to those structures is not allowed because their definitions reside in private headers. The README recommends using the public `png_set_<chunk>` and `png_get_<chunk>` functions instead.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/pnggroup-libpng)Was this useful?