PNG: The Definitive Guide

 in
There are times when the right person, at the right time, with the right talent, produces a work which rightfully deserves the title of “definitive guide”. This is one of those times.
  • Author: Greg Roelofs

  • Publisher: O'Reilly & Associates

  • E-mail: info@ora.com

  • URL: http://www.ora.com/

  • Price: $26.36

  • ISBN: 1565925424

  • Reviewer: Michael J. Hammel

As a writer who prides himself on being truly good at many things but not great at anything, I often take a somewhat timid approach to anything calling itself “definitive”. What nerve it must take to think of yourself as such an expert! Yet there are times when the right person, at the right time, with the right talent, produces a work which rightfully deserves the title of “definitive guide”. This is one of those times.

PNG—The Definitive Guide is Greg Roelofs' description of the design and use of PNG. PNG is a specification for a raster image file format. Greg's text, published by O'Reilly, is a clear and thorough exploration of the topic. Ranging from the early history of the design to detailed programming information on chunks and gamma correction to application support for this new format, the text is a complete descriptive volume on the subject.

Pronounced “ping” according to Greg (although I have a hard time not vocalizing the three letters separately), PNG has evolved over the past four years in response to limitations in design and licensing of the older GIF format. Greg is uniquely qualified to describe the format and tell its tale of evolution. He was there when Thomas Boutell first announced the project, and has written numerous articles on the subject—including being one of the few contributing authors I've ever had to my “Graphics Muse” column in Linux Gazette (http://www.linuxgazette.com/).

The text is divided into three parts: Using PNG, The Design of PNG and Programming with PNG. The specification for PNG is platform-independent, and Greg keeps true to this philosophy with this text. It covers everything from Linux to Windows to BeOS to OS/2; however, the first section does finish with a focus on Macromedia's Fireworks 1.0, a decidedly non-Linux application.

Greg starts with a decent introduction to raster graphics in the first chapter. This leads into a long description of the things for which PNG is most useful. I found this section quite good. Although I knew there were advantages to using PNG, I never knew what the specific reasons were. One of the most important, in the near term if not immediately, will be its support of standardized color management.

Greg points out in part one that PNG does not compress as well as JPEG does, but that JPEG's compression algorithm can lead to some blockiness around sharp edges in an image. He explains that PNG perhaps makes a better format for intermediate editing than for web browsing. This makes sense. PNG has lossless compression, so repeated saves and reloads in your editing package will produce the same image each time. TIFF is an alternative, but TIFF's compression scheme doesn't offer the same speed vs. quality options that PNG does. PNG can also achieve extremely high levels of compression without data loss. Conversion to JPEG might be preferred when the image is prepared for the Web, but that could be done as a last step before publication. As Chapter 2 mentions, both MSIE and Netscape support PNG in their latest browsers, although to different levels, and neither fully supports transparency in their released versions.

Chapter 2 also has an interesting discussion on using content negotiation. This is where you specify a text file with a .var suffix containing text describing one of multiple choices for the image to be displayed. Apache supports this with the mod_negotiation module and determines which of the image files specified in the .var file to send to the browser. A fairly interesting topic if you are into supporting any browser on the planet.

Chapter 3 is a simple application reference guide for image viewers on multiple platforms which support the PNG format. Greg does a good job of researching many different platforms here.

Chapter 4 goes into several image-editing applications with support for PNG. Greg shows how an image can be created in each of four major applications—Photoshop 4 and 5, Paint Shop Pro and the GIMP—and then how that image can be saved with PNG.

Chapter 5 describes a number of command-line image processing tools that support conversion to or from the PNG format or provide information on PNG files. All of these tools run on Linux, and Greg provides download information at the end of each application-specific section of this chapter, as he does for every other application he discusses in the text. The chapter ends with a reference-style list of other conversion tools. Each entry includes OS and download information.

The first section of the book closes with a chapter on 3-D applications with support for PNG. Greg covers VRML browsers in the first part of this chapter and has short discussions on 3-D modelers and other 3-D applications in the latter half. Unfortunately, there isn't much support for VRML under Linux, and out of the few browsers and VRML applications available for Linux, even fewer still apparently support PNG. This seems strange, considering PNG has been adopted as one of two formats for VRML certification.

In producing this book, O'Reilly followed the same basic industry practice of stuffing a couple of color plates in the middle of the book. In this case, with only two pages of plates, they might as well have left them out. As with most graphics texts, the comparative images printed in black-and-white outside the color plates aren't very useful. The first one is a set of three images showing a child standing in what looks like one of those boxes your luggage must fit in to carry it onto an airplane. The three images are supposed to show the effects of quantization and dithering, but that's nearly impossible to see in this black-and-white image. There are full-color versions of these same images, which are also enlarged, in the two-page color plates in the middle of the book. These color images do show the differences in the images quite well. When will publishers realize that texts about graphics need to be in color? Yes, it increases the cost, but it also increases the informational value. I'm thankful SSC used four-color printing throughout when publishing my GIMP book.

One minor side note: O'Reilly placed one of those generally annoying advertisement cards at page 188. The card was physically connected to the binding. I tried to pull it out, and ripped the page. Fortunately, I didn't rip through any of the text on that page. They might want to think about adding perforations at the connecting point for the card.

Chapter 7 starts the second part of the book, covering the design of PNG. This chapter is an interesting history into the evolution of an Internet-supported standard like PNG. An interesting bit of trivia which I was not aware of comes at the end of the chapter, where Greg tells us that PNG has been adopted in response to the MHEG-5 UK Profile, by digital television makers like Sony, Phillips and Nokia for both televisions and set-top boxes. I hadn't thought much about bitmap formats for television—I guess there's a whole new area of graphics for me to explore.

Chapter 8 introduces the basic PNG specifications. Here you'll find a description of the chunk, the main building block of the PNG format. Chapter 9 moves into compression information. Although the second part of the book is technical in nature, end users will find useful hints sprinkled throughout. In Chapter 9, for example, there are tips that cover which image types to use (PNG vs. JPEG, for example) and what settings to look for, given the format chosen. Greg follows up with tips for programmers on using compression and filtering.

One of the reasons I jumped ship from programmer to writer was that I saw the world was full of people who could write code, but short on those who could explain that code. I still see many technical folks taking a shot at writing for the masses and falling short, often slipping back into the acronymal world of the techno-geek. Greg is one of a rare breed. His writing style is both clear and complete, detailed and comprehensible. They should give medals for this sort of writing or at least little gold sticky stars.

Chapter 10 moves into one of the more complex issues in computer graphics: gamma correction and precision color. Display devices differ from their hard copy brethren in many ways, and even in subtle ways from each other. Gamma correction helps to ensure an image displayed on one device looks the same on another. Some of the gamma-related features of PNG and how to use them are discussed here.

PNG is an extensible format, providing both a defined set of public chunks and a method for implementors to add their own private chunks. In Chapter 11, Greg covers many of the extensions described in the original specification or that have been officially registered. These include such topics as histogram information, suggested palettes for low-color displays, fractal-image support and pixel calibration. Each section of this chapter is short, providing a quick explanation for the purpose of the extension, and in some cases, detailed programming issues. Part two closes with a chapter on MNG, the multi-image format cousin of PNG. PNG doesn't handle animation formats; it wasn't designed to do so. Chapter 12 discusses MNG in some depth, but this format is both still evolving and fairly complex. The chapter does give a nice overview of the format, however.

Part three is a detailed discussion of the two reference libraries for the PNG specification, namely libpng and zlib. The latter is the standard compression library used with PNG images. Both libraries are freely available and not license-restricted. Chapters 13 through 15 present a thorough programming guide to both the libpng and zlib APIs, including numerous code examples. Chapter 16 closes the book with short notes on other libraries and specifications of interest to the PNG programmer.

Two additional sections follow Chapter 16. The first is a well-done, chapter by chapter bibliography (although not all chapters have references listed). The second is a glossary of terms. The definitions given here are quite good, most providing more than the typical one- or two-line descriptions found in other texts.

If it's not obvious by this point, I'll state it clearly: I really liked this text. Personally, I don't have a major need for information on the PNG format. Until it's more widely adopted by the people I work with (such as publishers when asking for screenshots or other artwork), I'll probably stick to using TIFF, but that's not related to why I like this text. I'm a writer, and writers perform a public function—they provide information (and/or entertainment). Not all writers do this well, especially technical writers. However, Greg has done a very good job with this text on PNG. He's covered the topic well, and he's done so with an understanding of his audience's needs. He's earned the right to call this book The Definitive Guide.

Michael J. Hammel (mjhammel@graphics-muse.org) is a graphic artist wanna-be, a writer and a software developer. He wanders the planet aimlessly in search of adventure, quiet beaches and an escape from the computers that dominate his life.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix