Skip to Main Content
PNG: The Definitive Guide
book

PNG: The Definitive Guide

by Greg Roelofs
June 1999
Intermediate to advanced content levelIntermediate to advanced
340 pages
10h 10m
English
O'Reilly Media, Inc.
Content preview from PNG: The Definitive Guide

Chapter 11. PNG Options and Extensions

In addition to the core chunk types described thus far, the Portable Network Graphics format supports a whole host of optional chunks for various purposes, from text annotations to conversion information. These are described in the following sections, very roughly in order of importance to the average user.

Background Color (bKGD)

  • Status: PNG Specification
  • Location: After PLTE, before first IDAT
  • Multiple: no

In some applications, notably web browsers, there is a natural background surrounding all images, against which images can be composited with transparency information. But standalone image viewers typically have no preferred background color or pattern and usually default to black, which may not be appropriate for some images. PNG therefore supports the concept of a preferred background color that can be used if nothing better is available.

The bKGD chunk is used for this purpose. Just as with the transparency chunk, tRNS (see Chapter 8, “PNG Basics”), the format of bKGD depends on the image type. For palette-based images it contains a single byte, whose value is the palette index of the color to be used for the background. For grayscale images, with or without alpha, the chunk contains a 2-byte, unscaled gray value, just as with tRNS--that is, the maximum allowed value is 2bit depth-1, even though it is stored as a 16-bit integer. And for truecolor images, the background chunk is exactly analogous to the grayscale version except that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Fundamental Data Compression

Fundamental Data Compression

Ida Mengyi Pu
Understanding Compression

Understanding Compression

Colt McAnlis, Aleks Haecky

Publisher Resources

ISBN: 9781565925427