libpng is the PNG reference library that provides C code to create and manipulate PNG (Portable Network Graphics) raster image files. libpng Home Page.
libpng is based on the PNG specification which is widely accepted and is a stable specification Current Status of PNG. PNG provides a patent-free replacement of GIF.
libpng uses zlib for its compression and decompression of PNG files.
The PNG specifications defines the file format for lossless bitmapped image files. Encoders write a compressed PNG image file in the specified format and decoders use this file format to read and decompress a PNG image file.
The structure of a PNG file consists of a PNG signature and a series of chunks. The PNG signature identifies the file to consist of a PNG image. The signature is followed by a series of chunks beginning with an IHDR chunk and ending with an IEND chunk. Each chunk consists of four parts - length, chunk type, chunk data and CRC.
The PNG specifications define the standard types of PNG chunks. The specifications categorize the standard chunks as standard critical chunks and standard ancillary chunks. It is imperative for all implementations to understand and render the standard critical chunks - IHDR, IDAT, PLTE and IEND. It is recommended that implemented encoders and decoders be able to write and read the ancillary chunks respectively.
In libpng, the implementation for ancillary chunks may be compiled out using feature(chunk) specific macros. These macros also affect the size of libpng structures.
Latest available version libpng 1.2.8 was released on Dec 3, 2004. The current release and previous two releases (1.2.7, 1.2.6) were bug fix releases. A patch is available for version 1.2.6 which was incorporated in release 1.2.7.
According to Glenn's emails: 1.0.18 is only for supporting old applications that were linked with 1.0.x libraries. New applications should only be linked with 1.2.8. The main difference between them is that 1.2.8 supports user memory operations which affects the layout of the png_struct. There isn't any current demand for version 1.3.0.
In the current version, the iTXt chunk handling feature is disabled by default. This feature is planned to be enabled by default in release 1.3.0 (whenever that happens). This will affect the size of libpng structures and hence result in ABI changes.
zlib 1.0.4 or later (recommended 1.2.3 or 1.1.4)
Links to extensive documentation for libpng are available at PNG Documentation. This webpage includes links to the PNG Specification and the online book PNG: The Definitive Guide
The manual for libpng is available here.
The API documentation is available with the source code distribution in files libpng.3, libpng.txt and example.c. These files explain the usage of libpng API.
Willem van Schaik's PngSuite is the "official" test suite for PNG. This test suite is a collection of graphic images. There's a simple test program pngtest.c that reads in an image file and writes it out again. It then compares the two files and if the two match, the basic functionality is tested out. The formal test suite comprises of a set of images used to test the compression and decompression algorithms of the library. There are some other informal test files that cause crashes (these may or may not have proper distribution licenses). Links to sets of PNG images can be found here.
The test program pngtest included in libpng tests the basic chunk handling, filtering, compression and decompression code by comparing the input and output of a PNG image.
Raw analysis data can be found here LibpngAnalysis.txt
Applications: blender, briquolo, chromium, dia, DirectFB, doxygen, fltk, Foo``Billard, gd, gdk-pixbuf, gimp, gnome-panel, gnuplot, graphviz, gwenview, Image``Magick, khunphan, lbreakout, mjpegtools, penguin_command, povray, rrdtool, timidity, tkimg, transfig, tuxpaint, wv, wxGTK, wxGTK-compat, xfig, xine-ui, xsane, xv, xzgv
Libraries: clanlib, gtk2, gxmhtml, imlib, imlib-loaders, libgdiplus, libwmf, qt3, qt3-devel, qt3-non-mt, xorg-x11, SDL_image, cups-libs
_init, _fini, png_create_info_struct, png_create_read_struct, png_destroy_read_struct, png_read_info, png_set_packing, png_set_strip_16, png_read_image, png_get_IHDR, png_get_valid, png_read_end, png_create_write_struct, png_set_expand, png_destroy_write_struct, png_write_info, png_write_end, png_set_IHDR, png_read_update_info, png_set_read_fn, png_get_io_ptr, png_init_io, png_set_gray_to_rgb, png_set_compression_level, png_set_filler, png_set_write_fn, png_write_image, png_set_tRNS, png_write_row, png_set_sig_bytes, png_set_PLTE, png_set_bgr, png_set_interlace_handling, png_set_swap, png_check_sig, png_error, png_warning, png_set_gamma, png_get_tRNS, png_get_PLTE, png_set_error_fn, png_get_text, png_get_rowbytes, png_get_progressive_ptr, png_set_progressive_read_fn, png_set_invert_mono,png_progressive_combine_row, png_process_data, png_set_text, png_set_pHYs, png_get_y_offset_pixels, png_get_x_offset_pixels, png_get_gAMA, png_get_error_ptr, png_get_bit_depth, png_write_rows, png_set_swap_alpha, png_set_gAMA, png_get_y_pixels_per_meter, png_get_x_pixels_per_meter, png_set_oFFs, png_write_chunk, png_set_shift, png_set_packswap, png_set_gray_1_2_4_to_8, png_set_sBIT, png_set_filter, png_read_row, png_malloc
The interfaces involved in implementing the standard critical chunks defined in the PNG specification are tentative candidates for the first phase of testing (Is that a fair assumption?) These interfaces have been listed here LibpngTest.txt
On some distributions, you may find multiple versions of the libpng library.
According to Glenn's email: 1.0.18 is only for supporting old applications that were linked with 1.0.x libraries. New applications should only be linked with 1.2.8. The main difference between them is that 1.2.8 supports user memory operations which affects the layout of the png_struct.
libpng-1.2.8, when compiled, creates shared-library with soname libpng12.so.0. In this case, the include library string would be -lpng12. For building applications, libpng-config file is provided that provides the include strings for directory paths, include options, compiler and preprocessor flags.
According to Glenn's other email: libpng.so.3 is to support legacy applications that were linked before the naming scheme was changed. In the future, libpng13.so.0 will *not* be accompanied by a libpng.so.4.
To add comments to this page, click on [wiki:LibPng/Comments User Comments] and select edit.