1 - 2 - 3 - 4 - 7 - 8 - A - B - C - D - E - F - G - H - I - J - L - M - N - O - P - R - S - T - U - V - W
image
Click on the red underlined text to get to the source
... PNG format provides a portable, legally unencumbered, well-
compressed, well-specified standard for lossless bitmapped image
files.
...
... PNG include:
* Indexed-color images of up to 256 colors.
* Streamability: files can be read and written serially, thus
allowing the file format ...
... allowing the file format to be used as a communications
protocol for on-the-fly generation and display of images.
* Progressive display: a suitably prepared image file can be
...
... protocol for on-the-fly generation and display of images.
* Progressive display: a suitably prepared image file can be
displayed as it is received over a communications link,
...
... displayed as it is received over a communications link,
yielding a low-resolution image very quickly followed by
gradual improvement of detail.
* Transparency: portions of the image ...
... image very quickly followed by
gradual improvement of detail.
* Transparency: portions of the image can be marked as
transparent, creating the effect of a non-rectangular image.
...
... * Transparency: portions of the image can be marked as
transparent, creating the effect of a non-rectangular image.
* Ancillary information: textual comments and other data can be
...
... * Ancillary information: textual comments and other data can be
stored within the image file.
* Complete hardware and platform independence.
...
... images of up to 48 bits per pixel.
* Grayscale images of up to 16 bits per pixel.
* Full alpha channel ...
... * Full alpha channel (general transparency masks).
* Image gamma information, which supports automatic display of
images with correct brightness/contrast regardless of the
...
... * Image gamma information, which supports automatic display of
images with correct brightness/contrast regardless of the
machines used to originate and display the image.
...
... images with correct brightness/contrast regardless of the
machines used to originate and display the image.
* Reliable, straightforward detection of file corruption.
* Faster initial presentation in progressive display mode.
...
... algorithms under legal challenge are used. (Some
considerable effort has been spent to verify this.)
* Well compressed: both indexed-color and truecolor images are
compressed as effectively as in any other widely used lossless
...
... This chapter discusses basic data representations used in PNG files,
as well as the expected representation of the image data.
...
... Image layout ...
...
Conceptually, a PNG image is a rectangular pixel array, with
pixels appearing left-to-right within each scanline, and scanlines
appearing top-to-bottom. (For progressive display purposes, the
...
... bit depth, which is the number of bits per
sample in the image data.
Three types of pixel are supported:
...
...
* An indexed-color pixel is represented by a single sample
that is an index into a supplied palette. The image bit
depth determines the maximum number of palette entries, but
...
... Filtering, Section 2.5). The filter type byte
is not considered part of the image data, but it is included in
the datastream sent to the compression step.
...
... pixel basis, can be included in grayscale and truecolor PNG
images.
An alpha value of zero represents full transparency, and a value
...
... opaque pixel. Intermediate
values indicate partially transparent pixels that can be combined
with a background image to yield a composite image. (Thus, alpha
...
... with a background image to yield a composite image. (Thus, alpha
is really the degree of opacity of the pixel. But most people
refer to alpha as providing transparency information, not opacity
...
...
Alpha channels can be included with images that have either 8 or
16 bits per sample, but not with images ...
... images that have either 8 or
16 bits per sample, but not with images that have fewer than 8
bits per sample. Alpha samples are represented with the same bit
...
... 8
bits per sample. Alpha samples are represented with the same bit
depth used for the image samples. The alpha sample for each pixel
is stored immediately following the grayscale or RGB samples of
...
... "unassociated" or "non-premultiplied" alpha. (Another common
technique is to store sample values premultiplied by the alpha
fraction; in effect, such an image is already composited against a
black background. PNG does not use premultiplied alpha.)
...
... Transparency control is also possible without the storage cost of
a full alpha channel. In an indexed-color image, an alpha value
can be defined for each palette entry. In grayscale and truecolor
images ...
... image, an alpha value
can be defined for each palette entry. In grayscale and truecolor
images, a single pixel value can be identified as being
"transparent". These techniques are controlled by the tRNS
ancillary chunk type.
...
... If no alpha channel nor tRNS chunk is present, all pixels in the
image are to be treated as fully opaque.
...
...
PNG allows the image data to be filtered before it is compressed.
Filtering can improve the compressibility of the data. The filter ...
...
A PNG image can be stored in interlaced order to allow progressive
display. The purpose of this feature is to allow images to "fade
...
... PNG image can be stored in interlaced order to allow progressive
display. The purpose of this feature is to allow images to "fade
in" when they are being displayed on-the-fly. Interlacing
slightly expands the file size on average, but it gives the user a
...
... meaningful display much more rapidly. Note that decoders are
required to be able to read interlaced images, whether or not they
actually perform progressive display.
...
... Interlace method 1, known as Adam7 after its author, Adam M.
Costello, consists of seven distinct passes over the image. Each
pass transmits a subset of the pixels in the image. The pass in
...
... Costello, consists of seven distinct passes over the image. Each
pass transmits a subset of the pixels in the image. The pass in
which each pixel is transmitted is defined by replicating the
following 8-by-8 pattern over the entire image ...
... image. The pass in
which each pixel is transmitted is defined by replicating the
following 8-by-8 pattern over the entire image, starting at the
upper left corner:
...
...
The data within each pass is laid out as though it were a complete
image of the appropriate dimensions. For example, if the complete
image is 16 by 16 pixels, then pass 3 will contain two scanlines,
...
... image of the appropriate dimensions. For example, if the complete
image is 16 by 16 pixels, then pass 3 will contain two scanlines,
each containing four pixels. When pixels have fewer than 8 bits,
...
... 8 bits,
each such scanline is padded as needed to fill an integral number
of bytes (see Image layout, Section 2.3). Filtering is done on
this reduced image ...
... Image layout, Section 2.3). Filtering is done on
this reduced image in the usual way, and a filter type byte is
transmitted before each of its scanlines (see Filter ...
... filters.
Caution: If the image contains fewer than five columns or fewer
than five rows, some passes will be entirely empty. Encoders and
...
...
PNG images can specify, via the gAMA chunk, the gamma
characteristic of the image with respect to the original scene.
...
... PNG images can specify, via the gAMA chunk, the gamma
characteristic of the image with respect to the original scene.
Display programs are strongly encouraged to use this information,
plus information about the display device they are using and room
...
... Display programs are strongly encouraged to use this information,
plus information about the display device they are using and room
lighting, to present the image to the viewer in a way that
reproduces what the image's original author saw as closely as
...
... lighting, to present the image to the viewer in a way that
reproduces what the image's original author saw as closely as
possible. See Gamma Tutorial (Chapter 13) if you aren't already
familiar with gamma issues.
...
... RGB
data in a PNG image can be specified via the cHRM chunk, allowing
more accurate color matching than gamma correction alone will
provide. See Color Tutorial (Chapter 14) if you aren't already
...
...
A PNG file can store text associated with the image, such as an
image description or copyright notice. Keywords are used to
...
... PNG file can store text associated with the image, such as an
image description or copyright notice. Keywords are used to
indicate what each text string represents.
...
... signature indicates that the remainder of the file contains a
single PNG image, consisting of a series of chunks beginning with
an IHDR chunk and ending with an IEND chunk.
...
... ancillary bit is 1 can safely ignore the chunk and proceed to
display the image. The time chunk (tIME) is an example of an
ancillary chunk.
...
... an unknown chunk in which the ancillary bit is 0 must indicate
to the user that the image contains information it cannot
safely interpret. The image header ...
... to the user that the image contains information it cannot
safely interpret. The image header chunk (IHDR) is an example
of a critical ...
... If a chunk's safe-to-copy bit is 0, it indicates that the chunk
depends on the image data. If the program has made any changes
to critical chunks, including addition, modification, deletion,
...
... critical chunks. A valid PNG image must contain an IHDR
chunk, one or more IDAT chunks, and an IEND chunk.
...
... 1 byte
Width and height give the image dimensions in pixels. They are
4-byte integers. Zero is an invalid value. The maximum for each
...
... Color type is a single-byte integer that describes the
interpretation of the image data. Color type codes represent
sums of the following values: 1 (palette used), 2 (color used),
and 4 (alpha channel ...
... integer that indicates the
method used to compress the image data. At present, only
compression method 0 (deflate ...
... compression with a 32K
sliding window) is defined. All standard PNG images must be
compressed with this scheme. The compression method field is
...
... integer that indicates the
preprocessing method applied to the image data before
compression. At present, only filter ...
... method is a single-byte integer that indicates the
transmission order of the image data. Two values are currently
defined: 0 (no interlace) or 1 (Adam7 interlace). See
Interlaced data order (Section 2.6) for details.
...
... second by pixel value 1, etc. The number of palette entries
must not exceed the range that can be represented in the image
bit depth (for example, 2^4 = 16 for a bit ...
... allow. In that case, any out-of-range pixel value found in the
image data is an error.
For color types 2 and 6 (truecolor and truecolor with alpha),
...
... the PLTE chunk is optional. If present, it provides a
suggested set of from 1 to 256 colors to which the truecolor
image can be quantized if the viewer cannot display truecolor
directly. If PLTE is not present, such a viewer will need to
select colors on its own, but it is often preferable for this
...
... 8 bits (1 byte) per sample
regardless of the image bit depth specification. In
particular, the palette is 8 bits ...
... 8 bits deep even when it is a
suggested quantization of a 16-bit truecolor image.
There is no requirement ...
... There is no requirement that the palette entries all be used by
the image, nor that they all be different.
...
... IDAT Image data ...
... data:
* Begin with image scanlines represented as described in
Image layout (Section 2.3); the layout and total size of
...
... * Begin with image scanlines represented as described in
Image layout (Section 2.3); the layout and total size of
this raw data are determined by the fields of IHDR.
* Filter ...
... this raw data are determined by the fields of IHDR.
* Filter the image data according to the filtering method
...
... compression algorithm.
To read the image data, reverse this process.
There can be multiple IDAT chunks; if so, they must appear
...
... IEND Image trailer ...
...
The bKGD chunk specifies a default background color to present
the image against. Note that viewers are not bound to honor
this chunk; a viewer can choose to use a different background.
...
... (For consistency, 2 bytes are used regardless of the image bit
depth.) The value is the gray level to be used as background.
...
... consistency, 2 bytes per sample are used regardless of the
image bit depth.) This is the RGB color to be used as
...
... PNG file can use the cHRM chunk to specify the 1931
CIE x,y chromaticities of the red, green, and blue primaries
used in the image, and the referenced white point. See Color
Tutorial (Chapter 14) for more information.
...
... cHRM is allowed in all PNG files, although it is of little
value for grayscale images.
If the encoder ...
... encoder does not know the chromaticity values, it should
not write a cHRM chunk; the absence of a cHRM chunk indicates
that the image's primary colors are device-dependent.
If the cHRM chunk appears, it must precede the first IDAT
...
... gAMA Image gamma ...
... camera (or simulated
camera) that produced the image, and thus the gamma of the
image with respect to the original scene. More precisely, the
...
... camera) that produced the image, and thus the gamma of the
image with respect to the original scene. More precisely, the
gAMA chunk encodes the file_gamma value, as defined in Gamma
Tutorial (Chapter 13).
...
...
If the encoder does not know the image's gamma value, it should
not write a gAMA chunk; the absence of a gAMA chunk indicates
that the gamma is unknown.
...
... hIST Image histogram ...
... integers. There must be exactly one entry for each entry in
the PLTE chunk. Each entry is proportional to the fraction of
pixels in the image that have that palette index; the exact
scale factor is chosen by the encoder.
...
... Histogram entries are approximate, with the exception that a
zero entry specifies that the corresponding palette entry is
not used at all in the image. It is required that a histogram
entry be nonzero if there are any pixels of that color.
...
...
When the palette is a suggested quantization of a truecolor
image, the histogram is necessarily approximate, since a
decoder may map pixels to palette entries differently than the
...
...
The pHYs chunk specifies the intended pixel size or aspect
ratio for display of the image. It contains:
Pixels per unit, X axis: 4 bytes ...
... Each depth specified in sBIT must be greater than zero and less
than or equal to the sample depth (which is 8 for indexed-color
images, and the bit depth given in IHDR for other color types).
...
... original precision, this can be done by right-shifting the
stored samples (the stored palette entries, for an indexed-
color image). The encoder must scale the data in such a way
that the high-order bits ...
... Textual information that the encoder wishes to record with the
image can be stored in tEXt chunks. Each tEXt chunk contains a
keyword and a text string, in the format:
...
... should be used where appropriate:
Title Short (one line) title or caption for image
Author Name of image's creator
...
... Title Short (one line) title or caption for image
Author Name of image's creator
Description Description of image (possibly long)
...
... Author Name of image's creator
Description Description of image (possibly long)
Copyright Copyright notice
Creation Time Time of original image ...
... image (possibly long)
Copyright Copyright notice
Creation Time Time of original image creation
Software Software used to create the image ...
... image creation
Software Software used to create the image
Disclaimer Legal disclaimer
Warning Warning of nature of content
...
... Warning Warning of nature of content
Source Device used to create the image
Comment Miscellaneous comment; conversion from
GIF ...
... tIME Image last-modification time ...
...
The tIME chunk gives the time of the last image modification
(not the time of initial image creation). It contains:
...
... The tIME chunk gives the time of the last image modification
(not the time of initial image creation). It contains:
Year: 2 bytes ...
... The tIME chunk is intended for use as an automatically-applied
time stamp that is updated whenever the image data is changed.
It is recommended that tIME not be changed by PNG editors that
...
... It is recommended that tIME not be changed by PNG editors that
do not change the image data. See also the Creation Time tEXt
keyword, which can be used for a user-supplied time.
...
...
The tRNS chunk specifies that the image uses simple
transparency: either alpha values associated with palette
entries (for indexed-color images ...
... image uses simple
transparency: either alpha values associated with palette
entries (for indexed-color images) or a single transparent
color (for grayscale and truecolor images). Although simple
...
... entries (for indexed-color images) or a single transparent
color (for grayscale and truecolor images). Although simple
transparency is not as elegant as the full alpha channel, it
...
... fully transparent, 255 is fully opaque,
regardless of image bit depth. The tRNS chunk must not contain
more alpha values than there are palette entries, but tRNS can
...
... (For consistency, 2 bytes are used regardless of the image bit
depth.) Pixels of the specified gray level are to be treated as
...
... consistency, 2 bytes per sample are used regardless of the
image bit depth.) Pixels of the specified color value are to be
treated as transparent (equivalent to alpha value 0); all other
...
... Standard keywords for tEXt and zTXt chunks:
Title Short (one line) title or caption for image
Author Name of image's creator
...
... Title Short (one line) title or caption for image
Author Name of image's creator
Description Description of image (possibly long)
...
... Author Name of image's creator
Description Description of image (possibly long)
Copyright Copyright notice
Creation Time Time of original image ...
... image (possibly long)
Copyright Copyright notice
Creation Time Time of original image creation
Software Software used to create the image ...
... image creation
Software Software used to create the image
Disclaimer Legal disclaimer
Warning Warning of nature of content
...
... Warning Warning of nature of content
Source Device used to create the image
Comment Miscellaneous comment; conversion from
GIF ...
... concatenation of the contents of all the IDAT
chunks makes up a zlib datastream as specified above. This
datastream decompresses to filtered image data as described elsewhere
in this document.
...
...
In the same vein, there is no required correlation between the
structure of the image data (i.e., scanline boundaries) and deflate
block boundaries or IDAT chunk boundaries. The complete image ...
... image data (i.e., scanline boundaries) and deflate
block boundaries or IDAT chunk boundaries. The complete image data
is represented by a single zlib datastream that is stored in some
number of IDAT chunks; a decoder ...
... zlib datastream as specified above. This datastream decompresses to
the user-readable text described by the chunk's keyword. Unlike the
image data, such datastreams are not split across chunks; each zTXt
chunk contains an independent zlib datastream.
...
... compression. The purpose of these filters is to prepare the
image data for optimum compression.
...
... filter algorithms to apply
on a scanline-by-scanline basis. In the image data sent to the
compression step, each scanline is preceded by a filter ...
... algorithms are applied to bytes, not to pixels,
regardless of the bit depth or color type of the image. The
filtering algorithms ...
... filtering algorithms work on the byte sequence formed by a
scanline that has been represented as described in Image layout
(Section 2.3). If the image includes an alpha channel ...
... scanline that has been represented as described in Image layout
(Section 2.3). If the image includes an alpha channel, the alpha
data is filtered in the same way as the image ...
... image includes an alpha channel, the alpha
data is filtered in the same way as the image data.
When the image ...
... image data.
When the image is interlaced, each pass of the interlace pattern
is treated as an independent image for filtering ...
... When the image is interlaced, each pass of the interlace pattern
is treated as an independent image for filtering purposes. The
filters ...
... transmitted during a pass, and the "previous scanline" is the one
previously transmitted in the same pass, not the one adjacent in
the complete image. Note that the subimage transmitted in any one
pass is always rectangular, but is of smaller width and/or height
than the complete image ...
... image. Note that the subimage transmitted in any one
pass is always rectangular, but is of smaller width and/or height
than the complete image. Filtering is not applied when this
subimage is empty.
...
... filters that refer to
the prior scanline, the entire prior scanline must be treated as
being zeroes for the first scanline of an image (or of a pass of
an interlaced image).
...
... being zeroes for the first scanline of an image (or of a pass of
an interlaced image).
To reverse the effect of a filter ...
... immediately above the current pixel on the prior line, and the
pixel just to the left of the pixel above. This implies that at
least one scanline's worth of image data will have to be stored by
the decoder at all times. Even though some filter ...
... PNG imposes no restriction on which filter types can be applied to
an image. However, the filters are not equally effective on all
types of data. See Recommendations for Encoders ...
... transmitted as the filtered scanline.
On the first scanline of an image (or of a pass of an interlaced
image), assume Prior(x) = 0 for all x.
...
... On the first scanline of an image (or of a pass of an interlaced
image), assume Prior(x) = 0 for all x.
To reverse the effect of the Up filter ...
...
For all x < 0, assume Raw(x) = 0. On the first scanline of an
image (or of a pass of an interlaced image), assume Prior(x) = 0
for all x.
...
... For all x < 0, assume Raw(x) = 0. On the first scanline of an
image (or of a pass of an interlaced image), assume Prior(x) = 0
for all x.
...
...
For all x < 0, assume Raw(x) = 0 and Prior(x) = 0. On the first
scanline of an image (or of a pass of an interlaced image), assume
Prior(x) = 0 for all x.
...
... For all x < 0, assume Raw(x) = 0 and Prior(x) = 0. On the first
scanline of an image (or of a pass of an interlaced image), assume
Prior(x) = 0 for all x.
...
... modifies text chunks, and a program that adds a suggested palette to
a truecolor PNG file. Ordinary image editors are not PNG editors in
this sense, because they usually discard all unrecognized information
...
... PNG editors in
this sense, because they usually discard all unrecognized information
while reading in an image. (Note: we strongly encourage programs
handling PNG files to preserve ancillary information ...
... Internet Assigned Numbers Authority (IANA) has registered
"image/png" as the Internet Media Type for PNG ...
... decoders may choose to also
support the interim media type "image/x-png" which was
in use before registration was complete.
...
... Multiple-image extension ...
...
PNG itself is strictly a single-image format. However, it may be
necessary to store multiple images within one file; for example,
...
... PNG itself is strictly a single-image format. However, it may be
necessary to store multiple images within one file; for example,
this is needed to convert some GIF files. In the future, a
...
... this is needed to convert some GIF files. In the future, a
multiple-image format based on PNG may be defined. Such a format
will be considered a separate file format ...
... signature. PNG-supporting applications may or may not
choose to support the multiple-image format.
See Rationale: Why not these features? (Section 12.3).
...
... be executed on the recipient's computer as a result of decoding
the PNG image.
The possible security risks ...
... subject to data
corruption. The only likely consequence of such corruption is
incorrectly displayed pixels within the image. Worse things might
happen if the CRC of the IHDR chunk is not checked and the width
...
... zeroes. This scheme cannot reproduce white exactly, since it does
not generate an all-ones maximum value; the net effect is to
darken the image slightly. This method is not recommended in
general, but it does have the effect of improving compression ...
... encoder might instead dither the low-order bits, improving
displayed image quality at the price of increasing file size.
In some applications the original source data may have a range ...
... for this case, although the shifting methods do not. It is
recommended that an sBIT chunk not be written for such images,
since sBIT suggests that the original data range was exactly
...
... point or high-precision integer form (perhaps from a computer
image renderer), then it is recommended that the encoder perform
its own gamma encoding ...
... integer
values for storage in the file. Applying gamma encoding at this
stage results in images with fewer banding artifacts at a given
sample depth, or allows smaller samples while retaining the same
visual quality.
...
... 1.0).
If the image is being written to a file only, the encoder_gamma
value can be selected somewhat arbitrarily. Values of 0.45 or 0.5
...
...
Some image renderers may simultaneously write the image to a PNG
file and display it on-screen. The displayed pixels should be
...
... SECAM) since video camera transfer functions are standardized.
Image scanners are less predictable. Their output samples may be
linear (gamma 1.0) since CCD sensors themselves are linear, or the
scanner hardware ...
... File format converters generally should not attempt to convert
supplied images to a different gamma. Store the data in the PNG
file without conversion, and record the source gamma if it is
...
... the input to the output file.
In some cases, the supplied image may be in an image format (e.g.,
TIFF ...
...
In some cases, the supplied image may be in an image format (e.g.,
TIFF) that can describe the gamma characteristic of the image ...
... image format (e.g.,
TIFF) that can describe the gamma characteristic of the image. In
such cases, a file format converter is strongly encouraged to
...
... write a PNG gAMA chunk that corresponds to the known gamma of the
source image. Note that some file formats specify the gamma of
the display system, not the camera ...
... If the encoder or file format converter does not know how an image
was originally created, but does know that the image ...
... image
was originally created, but does know that the image has been
displayed satisfactorily on a display with gamma display_gamma
under lighting conditions where a particular viewing_gamma is
...
... displayed satisfactorily on a display with gamma display_gamma
under lighting conditions where a particular viewing_gamma is
appropriate, then the image can be marked as having the
file_gamma:
...
...
This will allow viewers of the PNG file to see the same image that
the person running the file format converter saw. Although this
...
... the person running the file format converter saw. Although this
may not be precisely the correct value of the image gamma, it's
better to write a gAMA chunk with an approximately right value
than to omit the chunk and force PNG ...
... appropriate gamma.
On the other hand, if the image file is being converted as part of
a "bulk" conversion, with no one looking at each image, then it is
...
... On the other hand, if the image file is being converted as part of
a "bulk" conversion, with no one looking at each image, then it is
better to omit the gAMA chunk entirely. If the image gamma has to
...
... a "bulk" conversion, with no one looking at each image, then it is
better to omit the gAMA chunk entirely. If the image gamma has to
be guessed at, leave it to the decoder to do the guessing.
...
... encoder to determine the chromaticities
of the source display primaries, or to make a strong guess based
on the origin of the image or the hardware running it, then the
encoder ...
... Although you may still find the NTSC numbers listed in standards
documents, you won't find any images that actually use them.
Scanners that produce PNG ...
... chunk.
In the case of hand-drawn or digitally edited images, you have to
determine what monitor they were viewed on when being produced.
Many image ...
... images, you have to
determine what monitor they were viewed on when being produced.
Many image editing programs allow you to specify what type of
monitor you are using. This is often because they are working in
some device-independent space internally. Such programs have
...
...
If the encoder is compiled as a portion of a computer image
renderer that performs full-spectral rendering, the monitor values
that were used to convert from the internal device-independent
...
... does not store out of gamut colors.
If the computer image renderer performs calculations directly in
device-dependent RGB space, a cHRM chunk should not be written
...
... cHRM chunk.
There are often cases where an image's exact origins are unknown,
particularly if it began life in some other format. A few image
...
... There are often cases where an image's exact origins are unknown,
particularly if it began life in some other format. A few image
formats store calibration information, which can be used to fill
in the cHRM chunk. For example, all PhotoCD images ...
... image
formats store calibration information, which can be used to fill
in the cHRM chunk. For example, all PhotoCD images use the CCIR
709 primaries and D65 whitepoint, so these values can be written
into the cHRM chunk when converting a PhotoCD file. PhotoCD also
...
... approximated by a gAMA of 0.5. (PhotoCD can store colors outside
the RGB gamut, so the image data will require gamut mapping before
writing to PNG format.) TIFF ...
... It is not recommended that file format converters attempt to
convert supplied images to a different RGB color space. Store the
data in the PNG ...
... gamut mismatches and rounding errors. As with gamma conversions,
it's better to store the data losslessly and incur at most one
conversion when the image is finally displayed.
See also Recommendations for Decoders ...
... The alpha channel can be regarded either as a mask that
temporarily hides transparent parts of the image, or as a means
for constructing a non-rectangular image. In the first case, the
...
... temporarily hides transparent parts of the image, or as a means
for constructing a non-rectangular image. In the first case, the
color values of fully transparent pixels should be preserved for
...
... fully transparent pixels should be preserved for
future use. In the second case, the transparent pixels carry no
useful data and are simply there to fill out the rectangular image
area required by PNG. In this case, fully transparent ...
... compression.
Image authors should keep in mind the possibility that a decoder
will ignore transparency control. Hence, the colors assigned to
...
... transparency chunk is also available.
If the image has a known background color, this color should be
written in the bKGD chunk. Even decoders that ignore transparency
...
... may use the bKGD color to fill unused screen area.
If the original image has premultiplied (also called "associated")
alpha data, convert it to PNG's non-premultiplied format by
...
... PNG's non-premultiplied format by
dividing each sample value by the corresponding alpha value, then
multiplying by the maximum value for the image bit depth, and
rounding to the nearest integer ...
... A PLTE chunk can appear in truecolor PNG files. In such files,
the chunk is not an essential part of the image data, but simply
represents a suggested palette that viewers may use to present the
image ...
... image data, but simply
represents a suggested palette that viewers may use to present the
image on indexed-color display hardware. A suggested palette is
of no interest to viewers running on truecolor hardware ...
... consequence of developing the suggested palette.)
For images of color type 2 (truecolor without alpha channel), it
is recommended that the palette and histogram be computed with
...
... may or may not match the file's bKGD color, if any).
For images of color type 6 (truecolor with alpha channel), it is
recommended that a bKGD chunk appear and that the palette and
...
... channel), it is
recommended that a bKGD chunk appear and that the palette and
histogram be computed with reference to the image as it would
appear after compositing against the specified background color.
This definition is necessary to ensure that useful palette entries
...
... are generated for pixels having fractional alpha values. The
resulting palette will probably only be useful to viewers that
present the image against the same background color. It is
recommended that PNG editors delete ...
... delete or recompute the palette if
they alter or remove the bKGD chunk in an image of color type 6.
If PLTE appears without bKGD in an image ...
... image of color type 6.
If PLTE appears without bKGD in an image of color type 6, the
circumstances under which the palette was computed are
unspecified.
...
...
For images of color type 3 (indexed color), filter type 0 (None)
is usually the most effective. Note that color images ...
... images of color type 3 (indexed color), filter type 0 (None)
is usually the most effective. Note that color images with 256 or
fewer colors should almost always be stored in indexed color
format; truecolor format is likely to be much larger.
...
... bit depths less
than 8. For low-bit-depth grayscale images, it may be a net win
to expand the image to 8-bit ...
... bit-depth grayscale images, it may be a net win
to expand the image to 8-bit representation and apply filtering,
...
... but this is rare.
For truecolor and grayscale images, any of the five filters may
prove the most effective. If an encoder ...
...
For best compression of truecolor and grayscale images, we
recommend an adaptive filtering approach in which a filter ...
... Filtering according to these recommendations is effective on
interlaced as well as noninterlaced images.
...
... zTXt.
Placing large tEXt and zTXt chunks after the image data (after
IDAT) can speed up image display in some situations, since the
...
... Placing large tEXt and zTXt chunks after the image data (after
IDAT) can speed up image display in some situations, since the
decoder won't have to read over the text to get to the image ...
... image display in some situations, since the
decoder won't have to read over the text to get to the image data.
But it is recommended that small text chunks, such as the image
...
... decoder won't have to read over the text to get to the image data.
But it is recommended that small text chunks, such as the image
title, appear before IDAT.
...
... critical chunk type, for all private chunks that store information
that is not absolutely essential to view the image. Creation of
private critical chunks is discouraged because they render PNG ...
... Conversely, viewers running on display hardware with non-square
pixels are strongly encouraged to rescale images for proper
display.
...
... Truecolor image handling ...
... decoders
are required to accept all types of PNG image: indexed-color,
truecolor, and grayscale. Viewers running on indexed-color
display hardware ...
... truecolor, and grayscale. Viewers running on indexed-color
display hardware need to be able to reduce truecolor images to
indexed format for viewing. This process is usually called "color
quantization".
...
... quantization".
A simple, fast way of doing this is to reduce the image to a fixed
palette. Palettes with uniform color spacing ("color cubes") are
usually used to minimize the per-pixel computation. For
...
... palette. Palettes with uniform color spacing ("color cubes") are
usually used to minimize the per-pixel computation. For
photograph-like images, dithering is recommended to avoid ugly
contours in what should be smooth gradients; however, dithering
introduces graininess that can be objectionable.
...
...
The quality of rendering can be improved substantially by using a
palette chosen specifically for the image, since a color cube
usually has numerous entries that are unused in any particular
image ...
... image, since a color cube
usually has numerous entries that are unused in any particular
image. This approach requires more work, first in choosing the
palette, and second in mapping individual pixels to the closest
available color. PNG ...
... with gamma issues.
To produce correct tone reproduction, a good image display program
should take into account the gammas of the image file and the
...
... To produce correct tone reproduction, a good image display program
should take into account the gammas of the image file and the
display device, as well as the viewing_gamma appropriate to the
lighting conditions near the display. This can be done by
...
... integer samples into a normalized 0 to 1 floating point value, the
second undoes the gamma encoding of the image file to produce a
linear intensity value, the third adjusts for the viewing
conditions, the fourth corrects for the display system's gamma
...
... gcvideo = gbright^(viewing_gamma / (file_gamma*display_gamma))
so as to perform only one power calculation. For color images, the
entire calculation is performed separately for R, G, and B values.
...
... lookup table that gives the correct
output value for every possible sample value. This requires only
256 calculations per image (for 8-bit accuracy), not one or three
calculations per pixel. For an indexed-color image ...
... image (for 8-bit accuracy), not one or three
calculations per pixel. For an indexed-color image, a one-time
correction of the palette is sufficient, unless the image uses
...
... calculations per pixel. For an indexed-color image, a one-time
correction of the palette is sufficient, unless the image uses
transparency and is being displayed against a nonuniform
background.
...
... of real files.
When the incoming image has unknown gamma (no gAMA chunk), choose
a likely default file_gamma value, but allow the user to select a
new one if the result proves too dark or too light.
...
... CRT combined. You may not be able to find out what the lookup
table contains from within an image viewer application, so you may
have to ask the user what the system's gamma value is.
Unfortunately, different manufacturers use different ways of
...
... 1.0, since most computer displays live in brightly-lit rooms.
When viewing images that are digitized from video, or that are
destined to become video frames, the user might want to set the
viewing_gamma to about 1.25 regardless of the actual level of room
...
... lighting. This value of viewing_gamma is "built into" NTSC video
practice, and displaying an image with that viewing_gamma allows
the user to see what a TV set would show under the current room
lighting conditions. (This is not the same thing as trying to
...
... (except for appropriate gamma correction). This provides the
fastest display of PNG images. But unless the viewer uses exactly
the same display hardware as the original image ...
... images. But unless the viewer uses exactly
the same display hardware as the original image author used, the
colors will not be exactly the same as the original author saw,
particularly for darker or near-neutral colors. The cHRM chunk
...
...
Decoders can use the cHRM data to transform the image data from
RGB to XYZ and thence into a perceptually linear color space such
...
...
Decoders that are part of image processing applications might also
transform image data into CIE LAB space for analysis.
...
... Decoders that are part of image processing applications might also
transform image data into CIE LAB space for analysis.
In applications where color fidelity is critical ...
... architecture, or
advertising, decoders can transform the image data from source_RGB
to the display_RGB ...
... RGB
to the display_RGB space of the monitor used to view the image.
This involves calculating the matrix to go from source_RGB to XYZ
...
... Management System
(CMS) can pass the image data, gAMA and cHRM values to the CMS for
display or further processing.
...
... Decoders that provide color printing facilities can use the
facilities in Level 2 PostScript to specify image data in
calibrated RGB space or in a device-independent color space such
...
... Decoders can use the cHRM data to calculate an accurate grayscale
representation of a color image. Conversion from RGB to gray is
simply a case of calculating the Y (luminance) component of XYZ,
...
... ITU-BT709]. Do not use the original NTSC primaries, unless you
really do have an image color-balanced for such a monitor. Few
monitors ever used the NTSC primaries, so such images ...
... image color-balanced for such a monitor. Few
monitors ever used the NTSC primaries, so such images are probably
nonexistent these days.
...
...
The background color given by bKGD will typically be used to fill
unused screen space around the image, as well as any transparent
pixels within the image. (Thus, bKGD is valid ...
... unused screen space around the image, as well as any transparent
pixels within the image. (Thus, bKGD is valid and useful even
when the image ...
... image. (Thus, bKGD is valid and useful even
when the image does not use transparency.) If no bKGD chunk is
present, the viewer will need to make its own decision about a
suitable background color.
...
...
Viewers that have a specific background against which to present
the image (such as Web browsers) should ignore the bKGD chunk, in
effect overriding bKGD with their preferred background color or
background image ...
... image (such as Web browsers) should ignore the bKGD chunk, in
effect overriding bKGD with their preferred background color or
background image.
The background color given by bKGD is not to be considered
...
... The background color given by bKGD is not to be considered
transparent, even if it happens to match the color given by tRNS
(or, in the case of an indexed-color image, refers to a palette
index that is marked as transparent by tRNS). Otherwise one would
have to imagine something "behind the background" to composite ...
... composite a foreground image against a background image; the PNG
file defines the foreground image ...
... image; the PNG
file defines the foreground image and the transparency mask, but
not the background image. Decoders ...
... file defines the foreground image and the transparency mask, but
not the background image. Decoders are not required to support
this most general case. It is expected that most will be able to
...
... range 0 to 1. This computation should be
performed with linear (non-gamma-encoded) sample values. For
color images, the computation is done separately for R, G, and B
samples.
...
...
The following code illustrates the general case of compositing a
foreground image over a background image. It assumes that you
have the original pixel data available for the background image ...
... The following code illustrates the general case of compositing a
foreground image over a background image. It assumes that you
have the original pixel data available for the background image,
...
... image over a background image. It assumes that you
have the original pixel data available for the background image,
and that output is to a frame buffer for display. Other variants
...
... buffer for display. Other variants
are possible; see the comments below the code. The code allows
the sample depths and gamma values of foreground image, background
image, and frame buffer ...
... the sample depths and gamma values of foreground image, background
image, and frame buffer/CRT all to be different. Don't assume
they are the same without checking.
...
... the comments below.
01 int foreground[4]; /* image pixel: R, G, B, A */
02 int background[3]; /* background pixel: R, G, B */
03 int fbpix[3]; /* frame buffer ...
... 14 if (ialpha == 0) {
/*
* Foreground image is transparent here.
* If the background image is already in the frame
...
... * Foreground image is transparent here.
* If the background image is already in the frame
* buffer, there is nothing to do.
...
...
* If output is to another PNG image file instead of a frame
buffer, lines 21, 22, 33, and 34 should be changed to be
...
... copying pixel values from background to output file if alpha
is zero. Since alpha is typically either zero or one for
the vast majority of pixels in an image, this is a great
savings. No gamma computations are needed for most pixels.
* When the sample depths and gamma values all match, it may
...
... encoding
(lines 28-31, 33-34) and just perform line 32 using gamma-
encoded sample values. Although this doesn't hurt image
quality too badly, the time savings are small if alpha
values of zero and one are special-cased as recommended
...
... values of zero and one are special-cased as recommended
here.
* If the original pixel values of the background image are no
longer available, only processed frame buffer pixels left by
...
... longer available, only processed frame buffer pixels left by
display of the background image, then lines 30 and 31 need
to extract intensity from the frame buffer pixel values
...
...
When displaying a PNG image with full alpha channel, it is
important to be able to composite ...
... channel, it is
important to be able to composite the image against some
background, even if it's only black. Ignoring the alpha channel
...
... channel
will cause PNG images that have been converted from an
associated-alpha representation to look wrong. (Of course, if the
alpha channel ...
... alpha channel is a separate transparency mask, then ignoring alpha
is a useful option: it allows the hidden parts of the image to be
recovered.)
...
... Even if the decoder author does not wish to implement true
compositing logic, it is simple to deal with images that contain
only zero and one alpha values. (This is implicitly true for
grayscale and truecolor PNG ...
... opaque; that is, do
not replace partially transparent pixels by the background. This
approach will not yield very good results for images converted
from associated-alpha formats, but it's better than doing nothing.
...
... decoders can
improve perceived performance by displaying interlaced images
progressively. This means that as each pass is received, an
approximation to the complete image ...
... images
progressively. This means that as each pass is received, an
approximation to the complete image is displayed based on the data
received so far. One simple yet pleasing effect can be obtained
by expanding each received pixel to fill a rectangle covering the
...
...
If the decoder is merging the received image with a background
image, it may be more convenient just to paint the received pixel
...
... decoder is merging the received image with a background
image, it may be more convenient just to paint the received pixel
positions; that is, the "visit()" function sets only the pixel at
the specified row ...
... the specified row and column, not the whole rectangle. This
produces a "fade-in" effect as the new image gradually replaces
the old. An advantage of this approach is that proper alpha or
transparency processing can be done as each pixel is replaced.
...
... transparency processing can be done as each pixel is replaced.
Painting a rectangle as described above will overwrite
background-image pixels that may be needed later, if the pixels
eventually received for those positions turn out to be wholly or
partially transparent. Of course, this is only a problem if the
...
... eventually received for those positions turn out to be wholly or
partially transparent. Of course, this is only a problem if the
background image is not stored anywhere offscreen.
...
... hardware.
If the image has a tRNS chunk, the viewer will need to adapt the
suggested palette for use with its desired background color. To
do this, replace the palette entry closest to the tRNS color with
...
... are PLTE entries.
For images of color type 6 (truecolor with alpha channel), any
suggested palette should have been designed for display of the
...
... channel), any
suggested palette should have been designed for display of the
image against a uniform background of the color specified by bKGD.
Viewers should probably ignore the palette if they intend to use a
different background, or if the bKGD chunk is missing. Viewers
...
... very good.
If the viewer presents a transparent truecolor image against a
background that is more complex than a single color, it is
unlikely that the suggested palette will be optimal for the
...
... unlikely that the suggested palette will be optimal for the
composite image. In this case it is best to perform a truecolor
compositing step on the truecolor PNG image ...
... image. In this case it is best to perform a truecolor
compositing step on the truecolor PNG image and background image,
then color-quantize the resulting image ...
... compositing step on the truecolor PNG image and background image,
then color-quantize the resulting image.
...
... image and background image,
then color-quantize the resulting image.
The histogram chunk is useful when the viewer cannot provide as
...
...
The histogram chunk is useful when the viewer cannot provide as
many colors as are used in the image's palette. If the viewer is
only short a few colors, it is usually adequate to drop the
least-used colors from the palette. To reduce the number of
...
... existing palette. This amounts to performing a new color
quantization step; however, the existing palette and histogram can
be used as the input data, thus avoiding a scan of the image data.
If no palette or histogram chunk is provided, a decoder ...
... If no palette or histogram chunk is provided, a decoder can
develop its own, at the cost of an extra pass over the image data.
Alternatively, a default palette (probably a color cube) can be
used.
...
... A value representing a pixel's degree of transparency. The more
transparent a pixel, the less it hides the background against
which the image is presented. In PNG, alpha is really the degree
of opacity: zero alpha represents a completely transparent pixel,
...
... A chunk that provides additional information. A decoder can still
produce a meaningful image, though not necessarily the best
possible image, without processing the chunk.
...
... produce a meaningful image, though not necessarily the best
possible image, without processing the chunk.
Bit ...
... Channel
The set of all samples of the same kind within an image; for
example, all the blue samples in a truecolor image. (The term
...
... The set of all samples of the same kind within an image; for
example, all the blue samples in a truecolor image. (The term
"component" is also used, but not in this specification.) A
sample is the intersection of a channel ...
... Composite
As a verb, to form an image by merging a foreground image and a
background image, using transparency information to determine
...
... image by merging a foreground image and a
background image, using transparency information to determine
where the background should be visible. The foreground image is
...
... background image, using transparency information to determine
where the background should be visible. The foreground image is
said to be "composited against" the background.
...
... A chunk that must be understood and processed by the decoder in
order to produce a meaningful image from a PNG file.
...
... describe a byte sequence that is only a portion of a file. We
also use it to emphasize that a PNG image might be generated and
consumed "on the fly", never appearing in a stored file at all.
...
... Filter
A transformation applied to image data in hopes of improving its
compressibility. PNG uses only lossless ...
... Frame buffer
The final digital storage area for the image shown by a computer
display. Software causes an image to appear onscreen by loading
...
... The final digital storage area for the image shown by a computer
display. Software causes an image to appear onscreen by loading
it into the frame buffer.
...
...
Gamma
The brightness of mid-level tones in an image. More precisely, a
parameter that describes the shape of the transfer function for
one or more stages in an imaging pipeline. The transfer function
...
...
Grayscale
An image representation in which each pixel is represented by a
single sample value representing overall luminance (on a scale
from black to white). PNG ...
... from black to white). PNG also permits an alpha sample to be
stored for each pixel of a grayscale image.
Indexed color
...
...
Indexed color
An image representation in which each pixel is represented by a
single sample that is an index into a palette or lookup table.
...
...
Palette
The set of colors available in an indexed-color image. In PNG, a
palette is an array of colors defined by red, green, and blue
...
... Pixel
The information stored for a single grid point in the image. The
complete image is a rectangular array of pixels.
...
...
Sample
A single number in the image data; for example, the red value of a
pixel. A pixel is composed of one or more samples. When
discussing physical ...
... pixel. A pixel is composed of one or more samples. When
discussing physical data layout (in particular, in Image layout,
Section 2.3), we use "sample" to mean a number stored in the image
...
... physical data layout (in particular, in Image layout,
Section 2.3), we use "sample" to mean a number stored in the image
array. It would be more precise but much less readable to say
"sample or palette index" in that context ...
...
Truecolor
An image representation in which pixel colors are defined by
storing three samples for each pixel, representing red, green, and
blue intensities respectively. PNG ...
... blue intensities respectively. PNG also permits an alpha sample
to be stored for each pixel of a truecolor image.
White point
...
... GIF. In particular, PNG supports truecolor images. We know of no
widely used image format that losslessly compresses truecolor
...
... PNG supports truecolor images. We know of no
widely used image format that losslessly compresses truecolor
images as effectively as PNG ...
... widely used image format that losslessly compresses truecolor
images as effectively as PNG does. We hope that PNG will make use
...
... PNG does. We hope that PNG will make use
of truecolor images more practical and widespread.
Some form of transparency control is desirable for applications in
...
...
Some form of transparency control is desirable for applications in
which images are displayed against a background or together with
other images. GIF ...
... which images are displayed against a background or together with
other images. GIF provided a simple transparent-color
specification for this purpose. PNG ...
...
Robustness against transmission errors has been an important
consideration. For example, images transferred across Internet
are often mistakenly processed as text, leading to file
...
... JPEG) are far
from foolproof --- a poor choice of quality level can ruin
an image. To avoid user confusion and unintentional loss of
information, we feel it is best to keep lossy and lossless
...
... Again, this is in the name of promoting portability. CMYK,
in particular, is far too device-dependent to be useful as a
portable image representation.
* There is no standard chunk for thumbnail views of images.
...
... portable image representation.
* There is no standard chunk for thumbnail views of images.
In discussions with software vendors ...
... vendors keep thumbnails in separate files to accommodate
varied image formats; they are not going to stop doing that
simply because of a thumbnail chunk in one new format.
Proprietary chunks containing vendor-specific ...
...
PNG also does not support multiple images in one file. This
restriction is a reflection of the reality that many applications
do not need and will not support multiple images ...
... images in one file. This
restriction is a reflection of the reality that many applications
do not need and will not support multiple images per file. In any
case, single images are a fundamentally different sort of object
...
... do not need and will not support multiple images per file. In any
case, single images are a fundamentally different sort of object
from sequences of images. Rather than make false promises of
...
... case, single images are a fundamentally different sort of object
from sequences of images. Rather than make false promises of
interchangeability, we have drawn a clear distinction between
single-image ...
... images. Rather than make false promises of
interchangeability, we have drawn a clear distinction between
single-image and multi-image formats. PNG is a single-image ...
... interchangeability, we have drawn a clear distinction between
single-image and multi-image formats. PNG is a single-image
...
... image and multi-image formats. PNG is a single-image
format. (But see Multiple-image extension, Section 8.4.)
...
... compression method
would avoid that problem, GIF does not support truecolor images,
alpha channels, or gamma correction. The spec has more subtle
...
...
IFF has also been suggested, but is not suitable in detail:
available image representations are too machine-specific or not
adequately compressed. The overall chunk structure of IFF is a
useful concept that PNG ...
... Lossless JPEG is not suitable because it does not provide for the
storage of indexed-color images. Furthermore, its lossless
truecolor compression ...
... implement than GIF's line-wise interlacing. It also costs a
little more in file size. However, it yields an initial image
eight times faster than GIF (the first pass transmits only 1/64th
...
... of the pixels, compared to 1/8th for GIF). Although this initial
image is coarse, it is useful in many situations. For example, if
the image is a World Wide Web ...
... image is coarse, it is useful in many situations. For example, if
the image is a World Wide Web imagemap that the user has seen
before, PNG ...
... Preliminary results show that small text in an interlaced PNG
image is typically readable about twice as fast as in an
equivalent GIF, i.e., after PNG ...
... equivalent GIF, i.e., after PNG's fifth pass or 25% of the image
data, instead of after GIF's third pass or 50%. This is again due
...
... It might seem natural to standardize on storing sample values that
are linearly proportional to light intensity (that is, have gamma
of 1.0). But in fact, it is common for images to have a gamma of
less than 1. There are three good reasons for this:
...
... intensity information. This causes the video signal to have
a gamma of about 0.5 relative to the light intensity in the
original scene. Thus, images obtained by frame-grabbing
video already have a gamma of about 0.5.
* The human eye has a nonlinear response to intensity, so
...
... linear encoding of samples either wastes sample codes in
bright areas of the image, or provides too few sample codes
to avoid banding artifacts in dark areas of the image, or
...
... bright areas of the image, or provides too few sample codes
to avoid banding artifacts in dark areas of the image, or
both. At least 12 bits per sample are needed to avoid
...
... image
intensity range. An image gamma in the range 0.3 to 0.5
allocates sample values in a way that roughly corresponds to
...
... 8 bits/sample are enough to
avoid artifacts caused by insufficient sample precision in
almost all images. This makes "gamma encoding" a much
better way of storing digital images ...
... images. This makes "gamma encoding" a much
better way of storing digital images than the simpler linear
encoding.
...
... correction hardware and no software willing to provide gamma
correction either. In these cases, the images have had
their lighting and color chosen to look best on this
platform --- they can be thought of as having "manual" gamma
...
... their lighting and color chosen to look best on this
platform --- they can be thought of as having "manual" gamma
correction built in. To see what the image author intended,
it is necessary to treat such images as having a file_gamma
...
... correction built in. To see what the image author intended,
it is necessary to treat such images as having a file_gamma
value in the range 0.4-0.6, depending on the room lighting
...
... level that the author was working in.
In practice, image gamma values around 1.0 and around 0.5 are both
widely found. Older image standards such as GIF ...
... In practice, image gamma values around 1.0 and around 0.5 are both
widely found. Older image standards such as GIF often do not
account for this fact. The JFIF standard specifies that images ...
... image standards such as GIF often do not
account for this fact. The JFIF standard specifies that images in
that format should use linear samples, but many JFIF images found
...
... account for this fact. The JFIF standard specifies that images in
that format should use linear samples, but many JFIF images found
on the Internet actually have a gamma somewhere near 0.4 or 0.5.
...
... on the Internet actually have a gamma somewhere near 0.4 or 0.5.
The variety of images found and the variety of systems that people
display them on have led to widespread problems with images
...
... The variety of images found and the variety of systems that people
display them on have led to widespread problems with images
appearing "too dark" or "too light".
...
...
PNG expects viewers to compensate for image gamma at the time that
the image is displayed. Another possible approach is to expect
...
... PNG expects viewers to compensate for image gamma at the time that
the image is displayed. Another possible approach is to expect
encoders to convert all images ...
... image is displayed. Another possible approach is to expect
encoders to convert all images to a uniform gamma at encoding
time. While that method ...
... correction capability.
Since there will always be images with no gamma or an incorrect
recorded gamma, good viewers will need to incorporate gamma
adjustment code anyway. Gamma correction at viewing time is thus
...
... PNG uses "unassociated" or "non-premultiplied" alpha so that
images with separate transparency masks can be stored losslessly.
Another common technique, "premultiplied alpha", stores pixel
values premultiplied by the alpha fraction; in effect, the image ...
... images with separate transparency masks can be stored losslessly.
Another common technique, "premultiplied alpha", stores pixel
values premultiplied by the alpha fraction; in effect, the image
is already composited against a black background. Any image data
...
... values premultiplied by the alpha fraction; in effect, the image
is already composited against a black background. Any image data
hidden by the transparency mask is irretrievably lost by that
method ...
... zero.
Some image rendering techniques generate images with premultiplied
alpha (the alpha value actually represents how much of the pixel
...
...
Some image rendering techniques generate images with premultiplied
alpha (the alpha value actually represents how much of the pixel
is covered by the image ...
... images with premultiplied
alpha (the alpha value actually represents how much of the pixel
is covered by the image). This representation can be converted to
PNG by dividing the sample values by alpha, except where alpha is
...
... filtering can
significantly reduce the compressed size of truecolor and
grayscale images. Filtering is also sometimes of value on
indexed-color images ...
... images. Filtering is also sometimes of value on
indexed-color images, although this is less common.
The filter ...
... performance. Tests have shown that filtering is
usually ineffective for images with fewer than 8 bits per sample,
so providing pixelwise filtering ...
... 8 bits per sample,
so providing pixelwise filtering for such images would be
pointless. For 16 bit/sample data, bytewise filtering ...
... away to almost nothing, so there is little storage cost compared
to a fixed filter specified for the whole image. And the
potential benefits of adaptive filtering are too great to ignore.
...
... In particular, an adaptive filter can change behavior for
successive passes of an interlaced image; a fixed filter cannot.
...
... graphics file formats include the ability to store some
textual information along with the image. But many applications
need more than that: they want to be able to store several
identifiable pieces of text. For example, a database ...
... A separate CRC is provided for each chunk in order to detect
badly-transferred images as quickly as possible. In particular,
critical data such as the image ...
... images as quickly as possible. In particular,
critical data such as the image dimensions can be validated before
being used.
...
... graphics would be a critical
chunk, since if ignored, important parts of the intended image
would be missing. A chunk carrying the Mandelbrot set coordinates
for a fractal image ...
... image
would be missing. A chunk carrying the Mandelbrot set coordinates
for a fractal image would be ancillary, since other applications
could display the image without understanding what the image ...
... for a fractal image would be ancillary, since other applications
could display the image without understanding what the image
represents. In general, a chunk type should be made critical ...
... image would be ancillary, since other applications
could display the image without understanding what the image
represents. In general, a chunk type should be made critical only
...
... critical only
if it is impossible to display a reasonable representation of the
intended image without interpreting that chunk.
The public/private property bit ...
... PNG file is modified, certain ancillary chunks may need to
be changed to reflect changes in other chunks. For example, a
histogram chunk needs to be changed if the image data changes. If
the file editor does not recognize histogram chunks, copying them
blindly to a new output file is incorrect; such chunks should be
...
...
A viewer may not be able to provide as many colors as are listed
in the image's palette. (For example, some colors could be
reserved by a window system.) To produce the best results in this
situation, it is helpful to have information about the frequency
...
... with which each palette index actually appears, in order to choose
the best palette for dithering or to drop the least-used colors.
Since images are often created once and viewed many times, it
makes sense to calculate this information in the encoder ...
... encoder to provide it.
Other image formats have usually addressed this problem by
specifying that the palette entries should appear in order of
frequency of use. That is an inferior solution, because it
...
... histogram provides the information needed to choose such a target
palette without making a pass over the image data.
...
... If the overall gamma of an imaging system is 1.0, its output is
linearly proportional to its input. This means that the ratio
between the intensities of any two areas in the reproduced image
will be the same as it was in the original scene. It might seem
that this should always be the goal of an imaging system: to
...
... is not the case.
When the reproduced image is to be viewed in "bright surround"
conditions, where other white objects nearby in the room have
about the same brightness as white in the image ...
... image is to be viewed in "bright surround"
conditions, where other white objects nearby in the room have
about the same brightness as white in the image, then an overall
gamma of 1.0 does indeed give real-looking reproduction of a
natural scene. Photographic prints viewed under room light and
...
... surround" viewing conditions.
However, sometimes images are intended to be viewed in "dark
surround" conditions, where the room is substantially black except
for the image ...
... images are intended to be viewed in "dark
surround" conditions, where the room is substantially black except
for the image. This is typical of the way movies and slides
(transparencies) are viewed by projection. Under these
circumstances, an accurate reproduction of the original scene
...
... (transparencies) are viewed by projection. Under these
circumstances, an accurate reproduction of the original scene
results in an image that human viewers judge as "flat" and lacking
in contrast. It turns out that the projected image needs to have
...
... results in an image that human viewers judge as "flat" and lacking
in contrast. It turns out that the projected image needs to have
a gamma of about 1.5 relative to the original scene for viewers to
judge it "natural". Thus, slide film is designed to have a gamma
...
... There is also an intermediate condition called "dim surround",
where the rest of the room is still visible to the viewer, but is
noticeably darker than the reproduced image itself. This is
typical of television viewing, at least in the evening, as well as
subdued-light computer work areas. In dim surround conditions,
...
... typical of television viewing, at least in the evening, as well as
subdued-light computer work areas. In dim surround conditions,
the reproduced image needs to have a gamma of about 1.25 relative
to the original scene in order to look natural.
...
... applies equally well to computer monitors. Thus, a PNG viewer
trying to achieve the maximum realism for the images it displays
really needs to know what the room lighting conditions are, and
adjust the gamma of the displayed image ...
... images it displays
really needs to know what the room lighting conditions are, and
adjust the gamma of the displayed image accordingly.
If asking the user about room lighting conditions is inappropriate
...
... assuming 2.5 is likely to be pretty accurate.
There are various images around that purport to measure gamma,
usually by comparing the intensity of an area containing
alternating white and black with a series of areas of continuous
...
... alternating white and black with a series of areas of continuous
gray of different intensity. These are usually not reliable.
Test images that use a "checkerboard" pattern of black and white
are the worst, because a single white pixel will be reproduced
considerably darker than a large area of white. An image ...
... images that use a "checkerboard" pattern of black and white
are the worst, because a single white pixel will be reproduced
considerably darker than a large area of white. An image that
uses alternating black and white horizontal lines (such as the
"gamma.png" test image ...
... image that
uses alternating black and white horizontal lines (such as the
"gamma.png" test image at
ftp://ftp.uu.net/graphics/png/images ...
... image at
ftp://ftp.uu.net/graphics/png/images/suite/gamma.png) is much
better, but even it may be inaccurate at high "picture" settings
on some CRTs.
...
... sensitive to its picture adjustment, and also affected by ambient
light. Furthermore, CRTs spread some light from bright areas of
an image into nearby darker areas; a single bright spot against a
black background may be seen to have a "halo". Your measuring
technique will need to minimize the effects of this.
...
...
Because of the difficulty of measuring gamma, using either test
images or measuring equipment, you're usually better off just
assuming gamma is 2.5 rather than trying to measure it.
...
... A CRT has a gamma of 2.5, and we can't change that. To get an
overall gamma of 1.0 (or somewhere near that) for an imaging
system, we need to have at least one other component of the "image
pipeline" that is nonlinear. If, in fact, there is only one
nonlinear stage in addition to the CRT, then it's traditional to
...
... SMPTE-170M], but its behavior can be well
approximated by a power function with a gamma of 0.5. When the
resulting image is displayed on a CRT with a gamma of 2.5, the
image on screen ends up with a gamma of about 1.25 relative to the
...
... resulting image is displayed on a CRT with a gamma of 2.5, the
image on screen ends up with a gamma of about 1.25 relative to the
original scene, which is appropriate for "dim surround" viewing.
...
... Thus, gamma correction sometimes happens before the frame buffer,
sometimes after. As long as images created in a particular
environment are always displayed in that environment, everything
...
... created in a particular
environment are always displayed in that environment, everything
is fine. But when people try to exchange images, differences in
gamma correction conventions often result in images that seem far
...
... is fine. But when people try to exchange images, differences in
gamma correction conventions often result in images that seem far
too bright and washed out, or far too dark and contrasty.
...
... In an ideal world, sample values would be stored in floating
point, there would be lots of precision, and it wouldn't really
matter much. But in reality, we're always trying to store images
in as few bits as we can.
...
... green, and blue to have enough precision in intensity. With any
less than that, we will sometimes see "contour bands" or "Mach
bands" in the darker areas of the image, where two adjacent sample
values are still far enough apart in intensity for the difference
to be visible.
...
... buffer, we can get
away with using many fewer bits to store the image. In fact, 8
bits per color is almost always sufficient to avoid contouring
artifacts. This is because, since gamma correction is so closely
...
... sample codes to intensity values in a manner that approximates how
visible those intensity changes are to the eye. Compared to a
linear-sample image, we allocate fewer sample values to brighter
parts of the tonal range and more sample values to the darker
...
... range.
Thus, for the same apparent image quality, images using gamma-
encoded sample values need only about two-thirds as many bits ...
...
Thus, for the same apparent image quality, images using gamma-
encoded sample values need only about two-thirds as many bits of
...
... encoded sample values need only about two-thirds as many bits of
storage as images using linear samples.
General gamma handling
...
...
When more than two nonlinear transfer functions are involved in
the image pipeline, the term "gamma correction" becomes too vague.
If we consider a pipeline that involves capturing (or calculating)
an image ...
... image pipeline, the term "gamma correction" becomes too vague.
If we consider a pipeline that involves capturing (or calculating)
an image, storing it in an image file, reading the file, and
displaying the image ...
... If we consider a pipeline that involves capturing (or calculating)
an image, storing it in an image file, reading the file, and
displaying the image on some sort of display screen, there are at
...
... image, storing it in an image file, reading the file, and
displaying the image on some sort of display screen, there are at
least 5 places in the pipeline that could have nonlinear transfer
functions. Let's give each a specific name for their
...
... encoding_gamma
the gamma of any transformation performed by the software
writing the image file
decoding_gamma
...
... decoding_gamma
the gamma of any transformation performed by the software
reading the image file
LUT_gamma
...
...
file_gamma
the gamma of the image in the file, relative to the original
scene. This is
...
... viewing_gamma
the overall gamma that we want to obtain to produce pleasing
images --- generally 1.0 to 1.5.
The file_gamma value, as defined above, is what goes in the gAMA
...
... correction has been done on the sample values in the file, and we
could call them "gamma corrected" samples. However, since there
can be so many different values of gamma in the image display
chain, and some of them are not known at the time the image is
...
... can be so many different values of gamma in the image display
chain, and some of them are not known at the time the image is
written, the samples are not really being "corrected" for a
specific display condition. We are really using a power function
...
... instead of "gamma corrected" samples.
When displaying an image file, the image decoding program is
responsible for making the overall gamma of the system equal to
...
...
When displaying an image file, the image decoding program is
responsible for making the overall gamma of the system equal to
the desired viewing_gamma, by selecting the decoding_gamma
...
...
However, PNG does not provide a way to specify that an image uses
this exact transfer function; the gAMA chunk always assumes a pure
power-law function. If we plot the two-part transfer function
...
... The cHRM chunk is used, together with the gAMA chunk, to convey
precise color information so that a PNG image can be displayed or
printed with better color fidelity than is possible without this
information. The preceding chapters state ...
... state how this information is
encoded in a PNG image. This tutorial briefly outlines the
underlying color theory for those who might not be familiar with
it.
...
... it.
Note that displaying an image with incorrect gamma will produce
much larger color errors than failing to use the chromaticity
data. First be sure the monitor set-up ...
... Calibrated, device-dependent color
Traditionally, image file formats have used uncalibrated, device-
dependent color. If the precise details of the original display
...
... dependent color. If the precise details of the original display
device are known, it becomes possible to convert the device-
dependent colors of a particular image to device-independent ones.
Making simplifying assumptions, such as working with CRTs (which
are much easier than printers), all we need to know are the XYZ
...
...
So why does PNG not store images in XYZ instead of RGB? Well, two
reasons. First, storing images ...
... images in XYZ instead of RGB? Well, two
reasons. First, storing images in XYZ would require more bits of
precision, which would make the files bigger. Second, all
...
... bits of
precision, which would make the files bigger. Second, all
programs would have to convert the image data before viewing it.
Whether calibrated or not, all variants of RGB are close enough
...
... RGB for your own monitor (to see the original
colors)
* print the image in Level 2 PostScript with better color
fidelity than a simple RGB ...
... RGB to CMYK conversion could provide
* calculate an optimal color palette
* pass the image data to a color management system
* etc.
...
... measurement. However, printer gamuts are typically smaller than
monitor gamuts, meaning that there can be many colors in a
displayable image that cannot physically be printed.
Converting image ...
... image that cannot physically be printed.
Converting image data from one device to another generally results
in gamut mismatches --- colors that cannot be represented exactly
on the destination ...
... range from a simple clip to elaborate nonlinear scaling
transformations, is termed gamut mapping. The aim is to produce a
reasonable visual representation of the original image.
Further reading
...
... PostScript.
Reference implementation and test images
A reference implementation in portable C is available from the PNG ...
... including commercial applications.
Test images are available from
ftp://ftp.uu.net/graphics/png/images/.
...
...
* Clarified meaning of a suggested-palette PLTE chunk in a
truecolor image that uses transparency
* Clarified exact semantics of sBIT and allowed sample depth
...
... Stone, M.C., W.B. Cowan, and J.C. Beatty, "Color gamut mapping and the printing of digital images", ACM Transactions on Graphics, vol 7 no 3 (1988), pp 249-292. ...
... Paeth, A.W., "Image File Compression Made Easy", in Graphics Gems II, James Arvo, editor. Academic Press, San Diego, 1991. ISBN 0-12-064480-0. ...
