<- ->
PREVIOUS        CONTENTS        NEXT

Preface

Contents:

About This Book
    Part I, Using PNG
    Part II, The Design of PNG
    Part III, Programming with PNG
Conventions Used in This Book
How to Contact Us
About the ``Second Edition'' (HTML Version)
History
    Version 1
    Version 2
Acknowledgments

Once upon a time, the only images were those painted on the walls of caves. Then came papyrus, stucco walls (and a chapel ceiling), the printing press, photography, television, and computers. Whether it's progress or not is a question for philosophers, but there is no doubt that creating, copying, modifying, and transmitting images has never been easier or faster than it is today.

PNG, the Portable Network Graphics image format, is one little piece of the puzzle. In PNG: The Definitive Guide, I attempt to make PNG a little less puzzling by explaining the motivations behind PNG's creation, the ways in which it can be used, and the tools that can manipulate it. The intended audience is anyone who deals with PNG images, whether as an artist, a programmer, or a surfer on the World Wide Web.

About This Book

This book covers a lot of ground, as one would expect from anything with the word ``Definitive'' in its title. It is divided into three main parts. As much as possible, each part is written so that it can be read independently of the others. Even individual chapters are written this way, within reason; to avoid too much repetition, I'll periodically refer to other chapters.

Part I, Using PNG

Part I is intended for designers, web site owners, casual image creators, and web surfers--anyone who wants a quick start on using PNG images in a variety of applications. Such users may need only a brief overview of PNG features, but they want to know what applications support the format and to what extent, how to invoke PNG-specific features within the applications, and how to work around certain bugs or incompatibilities in the applications. Of course, a book like this cannot possibly stay current, particularly not when it comes to software, but every effort has been made to ensure that the information is accurate as of the day this is written (mid-April 1999).

Chapter 1, "An Introduction to PNG", covers some basic concepts of computer images and file formats, explains how PNG fits in and where using it is most appropriate (and most inappropriate!), and ends with an in-depth look at an image-editing application with particularly good PNG support.

Chapter 2, "Applications: WWW Browsers and Servers", looks at PNG support in web browsers and servers and shows how to use the HTML OBJECT tag and server-side content negotiation to serve PNG images to browsers capable of viewing them.

Chapter 3, "Applications: Image Viewers", lists more than 75 applications capable of viewing PNG images, with support for a dozen operating systems. Viewers that are additionally capable of converting to or from other image formats are so noted.

Chapter 4, "Applications: Image Editors", looks at PNG support in five of the most popular image editors, showing how to invoke such features as gamma correction and alpha transparency, and indicating some of the problems unwary users may encounter.

Chapter 5, "Applications: Image Converters", covers five conversion applications in detail, including one specifically designed to optimize PNG images and another designed to test PNG images for conformance to the specification. In addition, the chapter lists another 16 dedicated image converters beyond those in Chapter 3, "Applications: Image Viewers".

Chapter 6, "Applications: VRML Browsers and Other 3D Apps", looks at PNG as a required texture format of the VRML 97 specification and investigates the level of conformance of seven browsers. It also lists a dozen PNG-supporting applications designed for the editing or rendering of 3D scenes.

Part II, The Design of PNG

Part II looks at the PNG format from an historical and technical perspective, detailing its structure and the rationale behind its design. Part II is intended for more technical readers who want to understand PNG to its core.

Chapter 7, "History of the Portable Network Graphics Format", looks at the events leading up to the creation of PNG, some of the design decisions that went into the format, how it has fared in the subsequent years, and what to expect for the future.

Chapter 8, "PNG Basics", covers the basic ``chunk'' structure of PNG files and compares PNG's level of support for various fundamental image types against that of other image formats.

Chapter 9, "Compression and Filtering", delves into the heart of PNG's compression engine, provides the results of some real-world compression tests, and offers a number of tips for improving compression to both users and programmers of the format.

Chapter 10, "Gamma Correction and Precision Color", discusses one of the least understood but most important features of PNG, its support for platform-independent image display. That is, in order for an image to appear the same way on different computer systems or even different print media, it is necessary for both the user and the program to understand and support gamma and color correction.

Chapter 11, "PNG Options and Extensions", details the optional features supported by PNG, including text annotations, timestamps, background colors, and other ancillary information.

Chapter 12, "Multiple-Image Network Graphics", is a brief look at PNG's multi-image cousin, MNG, which supports animations, slide shows, and even highly efficient storage of some types of single images.

Part III, Programming with PNG

Part III covers three working, libpng-based demo programs in detail, and lists a number of other toolkits that offer PNG support for various programming languages and platforms. It is intended for programmers who wish to add PNG support to their applications.

Chapter 13, "Reading PNG Images", is a detailed tutorial on how to write a basic PNG-reading display program in C using the official PNG reference library. The application is divided into a generic PNG back end and platform-specific front ends, of which two are provided (for 32-bit Windows and the X Window System).

Chapter 14, "Reading PNG Images Progressively", inverts the logic of the previous chapter's demo program, simulating the design of a web browser's display-as-you-go PNG code. Progressive display of interlaced, transparent PNG images over a background image is supported.

Chapter 15, "Writing PNG Images", shows how to create a basic PNG-writing program. The supplied code compiles into a simple command-line program under both Windows and Unix, and it includes support for interlacing, gamma correction, alpha transparency, and text annotations.

Chapter 16, "Other Libraries and Concluding Remarks", lists a number of alternative libraries and toolkits, both free and commercial, including ones for C, C++, JavaTM, Pascal, tcl/tk, Python, and Visual Basic. The chapter ends with a look back at what parts of the PNG design process worked and what didn't, and also a look forward at what lies ahead.

The References section lists technical references and resources for further information, both printed and electronic.

The Glossary defines a number of acronyms and technical terms used throughout the book.

Conventions Used in This Book

Italic is used for pathnames, filenames, program names, new terms where they are defined, newsgroup names, and Internet addresses, such as domain names, URLs, and email addresses.

Constant width is used to show code, commands, HTML tags, and computer-generated output.

Constant width bold is used in examples to show commands or other text that should be typed literally by the user.

Constant width italic is used in code fragments and examples to show variables for which a context-specific substitution should be made. The variable email address, for example, would be replaced by an actual email address.

[!]

CAUTION

This type of boxed paragraph indicates a tip, suggestion, general note, or caution.

How to Contact Us

Any information in this section referring to O'Reilly & Associates was valid only for the original, paper edition of the book. For this (HTML) version, the author may be contacted at:

roelofs @ pobox.com

The original text follows.

We have tested and verified all of the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!). Please let us know about any errors you find, as well as your suggestions for future editions, by writing:

O'Reilly & Associates, Inc.
101 Morris Street
Sebastopol, CA 95472
800-998-9938 (in the U.S. or Canada)
707-829-0515 (international/local)
707-829-0104 (fax)

You can also send us messages electronically. To subscribe to the mailing list or request a catalog, send email to:

nuts@oreilly.com

To ask technical questions or comment on the book, send email to:

bookquestions@oreilly.com

In addition, the author has set up a web page to support users of the book at:

http://www.libpng.org/pub/png/pngbook.html

This web page includes the complete source code for the demo programs described in Part III, "Programming with PNG" and may include additional fixes, improvements, new ports, and contributions. The page also includes an errata list. If the link ever breaks, check the following page for a pointer to the new location:

http://www.oreilly.com/catalog/pngdefg/

About the ``Second Edition'' (HTML Version)

Despite its public release more than four years after the publication of the first (paper) edition, this electronic version is fundamentally still a 1999 publication. That is, the updates and modifications that go beyond basic formatting and legal issues have been limited almost entirely to details that could have (or should have) been in the original. These include the addition of missing index entries and the lists of figures and tables, correction of numerous typos and other errata, restoration of color figures (using the original images!), and so forth. A handful of URLs have also been updated, but only those associated with the PNG home site and its close relatives (such as the zlib home site).

More specifically, the lists of applications with PNG and MNG support are woefully out of date, as are many (if not most) of the URLs and the specific nature of the support. Not only would updating them have required a huge investment in time, it also would have been completely redundant; the PNG and MNG home sites contain nearly complete lists of applications with PNG and MNG/JNG support, and they are updated regularly. Thus each chapter simply contains a link to the appropriate ``live'' web pages on libpng.org.

Note that I (Greg Roelofs) do intend to perform further updates as time permits, but these will not truly constitute a ``second edition'' in the usual sense. However, the Free Software Foundation is interested in publishing a fully updated edition of the book, so keep an eye on their site if you're interested.

History

This section, added according to the requirements of paragraph 4.I of the GNU FDL, describes the history of the document, not of the PNG format. (It may be moved to a separate page if it grows too unwieldy for the Preface.)

Version 2

This is the first online version of the book, released under the GNU Free Documentation License and published in July 2003. The original title and cover image are used with permission of the original publisher (O'Reilly and Associates). The complete text may be downloaded from SourceForge.net.

The principal change, obviously, is the fact that Version 2 is an electronic (HTML) edition rather than paper, intended to be read using any reasonably modern web browser. The original troff source was automatically converted by Lenny Muellner to HTML, which was then modified as follows:

  1. Filenames and all internal HTML references (chapters, subsections, table numbers, figure numbers) were off by one in the auto-conversion; fixed.
  2. Expanded table of contents and navigation sections at the top of each chapter to include subsections, not just chapters or top-level sections; added inter-chapter navigation bars (previous/contents/next).
  3. Converted ``Parts'' from verbatim replications of multiple chapters to corresponding excerpts from the table of contents.
  4. Changed auto-converted ``text images'' back to plain text using Unicode and Latin-1 entities (gamma, mu, Delta, delta, right arrow, a-with-ring, etc.).
  5. Added cover page, title page, copyright page, dedication, list of tables, list of figures, pages for original color plates (including captions), and license page.
  6. Recreated index and linked page numbers to appropriate HTML anchors; added new entries.
  7. Converted GIFs (from auto-conversion) to PNGs; rebuilt inlined, shrunken, grayscale figures with original, color source images wherever possible; added links to full-scale source images where necessary.
  8. Converted four text-mode listings in Chapter 9 to tables and updated table references accordingly; added mention of PNG chapter in the Lossless Compression Handbook.
  9. Restored 99 lines of missing text(!) in Chapter 14 (lost in auto-conversion, apparently).
  10. Corrected all errata noted on both O'Reilly's and the author's web pages, as well as several others in the index and bibliography.
  11. Updated web links associated with the book or its author (particularly cdrom.com).
  12. Reverted some O'Reillyisms (Gimp, frontend, backend) to original text (GIMP, front end [noun] or front-end [adjective], etc.).
  13. Cleaned up various bits of formatting.
  14. Added ``About'' and ``History'' sections to preface. These sections (together with some other additions) are in green text to distinguish them more easily from the original text.

As noted in the previous section, I intend to continue updating the HTML version, but this will probably be limited to fixing broken links and tying some of the sections more closely to appropriate pages on the PNG web site. Any such changes will be noted here in an ongoing changelog.

Acknowledgments

Though this book has only one author's name on the cover, it is the result of work by literally dozens of people. Glenn Randers-Pehrson's help was especially invaluable: he not only acted as a technical reviewer, but also contributed the interlace figure in Chapter 1, "An Introduction to PNG" and the haiku in Chapter 7, "History of the Portable Network Graphics Format"; he edited or co-edited not just one but all five of the PNG-related specifications available from the web site given in the previous section; and he authored virtually all of the MNG specification, wrote the incredibly useful pngcrush utility, and maintained libpng for the last year. On top of all that, his wife, Nancy, reviewed the book from a layperson's perspective; her insights were concise and invariably hit the mark. And Glenn's nephew, Michael, kindly contributed the haiku at the end of Chapter 16, "Other Libraries and Concluding Remarks". Thanks to the whole family!

I'd also like to thank my two other reviewers and colleagues in the PNG Group, Adam Costello and Tom Lane. Adam's help was absolutely indispensable in explaining the subtle and sometimes complicated ramifications of gamma and color correction and of international text formats; he also supplied code for one class of background patterns in the progressive PNG viewer. Tom, leader of the Independent JPEG Group and a member of the TIFF advisory committee, supplied background, corrections, and additional information on two of the image formats most relevant to PNG users, and he provided the progressive JPEG images in the color insert.

Thanks to Pieter van der Meulen for providing the impressive icicles image and for generating the alpha channel for it on short notice. Pieter also supplied code for another class of background patterns in the progressive viewer and was an understanding colleague when book-related deadlines occasionally took precedence over work.

For the chapter on image editors, I enlisted the aid of several people to help test the level of PNG support in various products: Anthony Argyriou for Paint Shop Pro; Chris Herborth for Photoshop 4; and two fine Macromedia engineers, Steven Johnson and John Ahlquist, for Fireworks. Jim Bala and Richard Koman provided additional assistance with Photoshop.

Thanks also to Michael Stokes for information about the sRGB standard and ICC profiles; Chris Lilley for additional information on gamma and color correction (including an incredibly well-written tutorial distributed via the University of Manchester) and for the chromaticity diagram in Chapter 10, "Gamma Correction and Precision Color"; Jean-loup Gailly for an informal review of Chapter 9, "Compression and Filtering" and, together with Mark Adler, the zlib compression engine at the heart of PNG; and John Bowler for information about the private Windows clipboard for PNG and how to access it.

Jas Sandu, Jed Hartman, and François Vidal provided timely and detailed information about PNG support in 3D applications, and Mathew Ignash did so for Amiga applications and APIs. Thanks to Delle Maxwell for providing the images she used in part of a VRML course; they not only prompted me to do some serious and quantifiable comparisons of compression in PNG and related image formats but also helped nail down some of the myriad ways in which bad PNG encoders can write large PNG files.

Portions of Chapter 7, "History of the Portable Network Graphics Format" appeared in the April 1997 issue of Linux Journal; thanks to Marjorie L. Richardson and Specialized Systems Consultants for permission to reuse the historical material here.

On the O'Reilly side, many, many thanks to editor Richard Koman for his help and patience with a first-time author. He is also responsible for making sure that this book would be of interest to a wider audience than just programmers. Thanks also to Lenny Muellner for being so very responsive on all sorts of picky formatting questions, to Tara McGoldrick, to Rob Romano and Alicia Cech for issues relating to the figures, to Nancy Kotary for her incredible patience during production, and to Edie Freedman for doing her best to get me a ``pnguin'' for the cover. For the online HTML version, many thanks to executive editor Laurie Petrycki for all of her help and patience in dealing with the legal and technical issues of the new format and the new license. And a very big thanks to O'Reilly and Associates as a whole for agreeing to rerelease the book under the GNU Free Documentation License.

A special thanks goes to Jennifer Niederst, who, while working on Web Design in a Nutshell, first suggested that I write this book. Many's the time over the past 10 months when I've debated whether it was a good suggestion or bad, but now that the book is done, I'm glad she did so.

Of course, without the patience of my sainted wife, Veronica, none of this could have happened. To little Lyra, I apologize for every time I uttered the phrase ``Daddy is working''; you'll see a lot more of me now. And to little Delenn--well, you aren't here yet, but I know someday you'll be miffed if your sister is mentioned and you aren't. :-)

Finally, thanks to everyone in the PNG Development Group, the ISO/IEC standardization committee, and all of the countless contributors to the PNG home site, who provided (and continue to provide) information about new or updated PNG-supporting applications, broken links, and suggestions for improvement. And without the continued support of Walnut Creek CD-ROM, the site would not be nearly as accessible and complete as it is; a very special and ongoing thanks to Christopher Mann and David Greenman.

If there's anyone I've missed, please rest assured it was not intentional! The brain cell is going, as a certain compression colleague has been known to say.


<- ->
PREVIOUS        CONTENTS        NEXT