From Wikipedia, the free encyclopedia
A PNG image with an 8-bit transparency channel (top). The same image is overlaid onto a checkered background (bottom), typically used ingraphics software
PNG supports palette-based images (with palettes of 24-bit RGB
PNG files nearly always use file extension "PNG" or "png" and are assigned MIME
Contents
[hide]
∙\t1 History and development
∙\t2 PNG Working Group
∙\t3 Technical details
o\t3.1 File header
o\t3.2 "Chunks" within the file
▪\t3.2.1 Critical chunks
▪\t3.2.2 Ancillary chunks
o\t3.3 Color depth
o\t3.4 Transparency of image
o\t3.5 Compression
▪\t3.5.1 Filtering
o\t3.6 Interlacing
o\t3.7 Animation
∙\t4 Comparison to other file formats
o\t4.1 Comparison to Graphics Interchange Format (GIF)
o\t4.2 Comparison to JPEG
o\t4.3 Comparison to JPEG-LS
o\t4.4 Comparison to TIFF
∙\t5 Software support
o\t5.1 Bitmap graphics editor support for PNG
o\t5.2 Web browser support for PNG
o\t5.3 Operating system support for PNG icons
∙\t6 File size and optimization software
o\t6.1 Compared to GIF
o\t6.2 File size factors
o\t6.3 Image editing software
o\t6.4 Optimizing tools
▪\t6.4.1 Ancillary chunk removal
▪\t6.4.2 Filter optimization
▪\t6.4.3 DEFLATE optimization
▪\t6.4.4 Wrapper tools
o\t6.5 Icon optimization
∙\t7 See also
∙\t8 References
∙\t9 Further reading
∙\t10 External links
o\t10.1 libpng.org
o\t10.2 W3C
o\t
See also: Graphics Interchange Format#Unisys and LZW patent enforcement
The motivation for creating the PNG format was in early 1995, after it became known that the Lempel–Ziv–Welch
A January 1995 precursory discussion thread, on the usenet newsgroup
▪
▪
▪
▪
▪
[edit
The original PNG specification was authored by an ad-hoc group of computer graphics experts and enthusiasts. Discussions and decisions about the format were done exclusively via email. The original authors listed on RFC 2083
Editor: Thomas Boutell
Authors' names in alphabetical order: Mark Adler
[edit
[edit
A PNG file starts with an 8-byte; the decimal values are 137 80 78 71 13 10 26 10. Each of the header bytes is there for a specific reason:[6]
Bytes | Purpose |
Has the high bit set to detect transmission systems that do not support 8 bit data | and to reduce the chance that a text file is mistakenly interpreted as a PNG, or vice versa. |
50 4E 47 | In ASCII, the letters PNG, allowing a person to identify the format easily if it is viewed in a text editor. |
0D 0A | A DOS-style line ending(CRLF) to detect DOS-Unix line ending conversion of the data. |
1A | A byte that stops display of the file under DOS when the command type has been used—the end-of-filecharacter |
0A | A Unix-style line ending (LF) to detect Unix-DOS line ending conversion. |
After the header comes a series of chunks, each of which conveys certain information about the image. Chunks declare themselves as criticalor ancillary, and a program encountering an ancillary chunk that it does not understand can safely ignore it. This chunk-based storage layer structure, similar in concept to a container format
A chunk consists of four parts: length (4 bytes), chunk type/name (4 bytes), chunk data (length bytes) and CRC
Length | Chunk type | Chunk data | CRC |
4 bytes | 4 bytes | Length bytes | 4 bytes |
The case of the first letter indicates if the chunk is critical or not. If the first letter is uppercase, the chunk is critical; if not, the chunk is ancillary. Critical chunks contain information that is necessary to read the file. If a decoder encounters a critical chunk it does not recognize, it must abort reading the file or supply the user with an appropriate warning.
The case of the second letter indicates if the chunk is "public" (either in the specification or the registry of special purpose public chunks) or "private" (not standardised). Uppercase is public and lowercase is private. This ensures that public and private chunk names can never conflict with each other (although two private chunk names could conflict).
The third letter must be uppercase to conform to the PNG specification. It is reserved for future expansion. Decoders should treat a chunk with a lower case third letter the same as any other unrecognised chunk.
The case of the fourth letter indicates if a chunk is safe to copy by editors that do not recognize it. If lowercase, the chunk may be safely copied regardless of the extent of modifications to the file. If uppercase, it may only be copied if the modifications have not touched any critical chunks.
[edit
A decoder must be able to interpret these to read and render a PNG file.
▪
▪
▪
▪
The PLTE chunk is essential for color type 3 (indexed color). It is optional for color types 2 and 6 (truecolor and truecolor with alpha) and it must not appear for color types 0 and 4 (grayscale and grayscale with alpha).
[edit
Other image attributes that can be stored in PNG files include gamma
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
The lowercase first letter in these chunks indicates that they are not needed for the PNG specification. The lowercase last letter in some chunks indicates that they are safe to copy, even if the application concerned does not understand them.
[edit
The number of channels will depend on whether the image is grayscale or color and whether it has an alpha channel
The color type is specified in the color type field, which is a bit field
Name | Colortype | Binary | Masks | |||
A | C | P | ||||
Grayscale | 0 | 0 | 0 | 0 | 0 | |
Indexed grayscale | 1 | 0 | 0 | 0 | 1 | Palette |
Truecolor | 2 | 0 | 0 | 1 | 0 | Color |
Indexed | 3 | 0 | 0 | 1 | 1 | Color | palette |
Grayscale & alpha | 4 | 0 | 1 | 0 | 0 | Alpha |
Indexed grayscale & alpha | 5 | 0 | 1 | 0 | 1 | Alpha | palette |
Truecolor & alpha | 6 | 0 | 1 | 1 | 0 | Alpha | color |
Indexed & alpha | 7 | 0 | 1 | 1 | 1 | Alpha | color | palette |
▪
▪
▪
▪
With indexed color images, the palette is always stored in RGB at a depth of 8 bits per channel (24 bits per palette entry). Additionally, an optional array of 8-bit alpha values of the palette entries may be included. The palette must not have more entries than the image bit depth allows for, but it may have fewer (for example, if an image only uses 90 colors then it does not need palette entries for all 256 colors).
Indexed color PNGs are allowed to have 1, 2, 4 or 8 bits per pixel by the standard; grayscale images with no alpha channel allow for 1, 2, 4, 8 or 16 bits per pixel. Everything else uses a bit depth per channel of either 8 or 16. The combinations this allows are given in the table above. The standard requires that decoders can read all supported color formats, but many image editors can only produce a small subset of them.
[edit
PNG offers a variety of transparency options. With truecolor and grayscale images either a single pixel value can be declared as transparent or an alpha channel
The scanning of pixel values for binary transparency is supposed to be performed before any color reduction to avoid pixels becoming unintentionally transparent. This is most likely to pose an issue for systems that can decode 16 bits per channel images (as they must to be compliant with the specification) but only output at 8 bits per channel (the norm for all but the highest end systems).
[edit
PNG uses a 2-stage compression process:
▪
▪
PNG uses a non-patented lossless data compression
[edit
PNG's filter method 0 can use the data in pixels A, B, and C to predict the value for X.
Before DEFLATE is applied, the data is precompressed, via a prediction method: a single filter methodis used for the entire image, while for each image line, a filter type is chosen that transforms the data so that it is hopefully more easily compressed.[11]
There is only one filter method in the current PNG specification (denoted method 0), and thus in practice the only choice is which filter type to apply to each line. For this method, the filter predicts the value of each pixel based on the values of previous neighboring pixels, and subtracts the predicted color of the pixel from the actual value, as in DPCM
There are five filter types for filter method 0; each type predicts the value of each byte (of the image data before filtering) based on the corresponding byte of the pixel to the left (A), above (B), above and to the left (C) or some combination thereof, and encodes the difference between the predicted value and the actual value. Filters are applied to byte values, not pixels; pixel values may be one or two bytes, or several values per byte, but never cross byte boundaries. The filter types are:[12]
Type byte | Filter name | Predicted value |
0 | None | Zero (so that the raw byte value passes through unaltered) |
1 | Sub | Byte A (to the left) |
2 | Up | Byte B (above) |
3 | Average | Mean of bytes A and B, rounded down |
4 | Paeth | A, B, or C, whichever is closest to p = A + B −C |
Compression is further improved by choosing filter types adaptively on a line-by-line basis. This improvement, and a heuristic method of implementing it commonly used by PNG-writing software, were created by Lee Daniel Crocker
If interlacing is used, each stage of the interlacing is filtered separately, meaning that the image can be progressively rendered as each stage is received; however, interlacing generally makes compression less effective.
[edit
An illustration of Adam7 interlacing over a 16×16 image.
PNG offers an optional 2-dimensional, 7-pass interlacing
However, the 7-pass scheme tends to reduce the data's compressibility more than simpler schemes.
[edit
PNG itself does not support animation at all. MNG
The complexity of MNG led to the proposal of APNG
[edit
[edit
▪
▪
▪
▪ When an alpha channel is added, up to bits per pixel (before compression) are possible.
▪
▪
▪
[edit
Composite image comparing JPEG and PNG: notice artifacts in JPEG versus solid PNG background.
JPEG
Also, JPEG suffers from generation loss
JPEG has historically been the format of choice for exporting images containing gradients, as it could handle the color depth much better than the GIF format. However, any compression by the JPEG would cause the gradient to become blurry, but a 24-bit PNG export of a gradient image often comes out identical to the source image, and at a small file size. As such, the PNG format is the optimal choice for exporting small, repeating gradients for web usage.
[edit
JPEG-LS
[edit
Tagged Image File Format
The most common general-purpose, lossless compression algorithm used with TIFF is Lempel–Ziv–Welch
[edit
[edit
Main article: Comparison of raster graphics editors
Popular graphics programs which support the PNG format include Adobe Photoshop, Corel's Photo-Paint and Paint Shop Pro, the GIMP,GraphicConverter, Helicon Filter, Inkscape, IrfanView, Konvertor, Universal Converter, Pixel image editor, Paint.NET and Xara. Some programs bundled with popular operating systems which support PNG include Microsoft's Paint and Apple's iPhoto and Preview, with the GIMP also often being bundled with popular Linux distributions.
Adobe Fireworks (formerly by Macromedia) uses PNG as its native file format, allowing other image editors and preview utilities to view the flattened image. However, Fireworks by default also stores meta data for layers, animation, vector data, text and effects. Such files should not be distributed directly. Fireworks can instead export the image as an optimized PNG without the extra meta data for use on web pages, etc.[23]
Some image processing programs have PNG compression problems, mainly related to lack of full implementation of the PNG compressor library.[citation needed
▪
▪
▪
Adobe's Fireworks is sometimes placed in this category, but its difficulties are less severe than the other entries. The confusion stems from a misunderstanding of the mechanics of its Save format: though PNGs, the intermediate images produced by that option include large, private chunks containing complete layer and vector information, which allows further, lossless editing. Properly saved with the Exportoption, Fireworks' PNGs are competitive with those produced by other image editors, but are no longer editable as anything but flattened bitmaps. Fireworks is unable to save size-optimized vector-editable PNGs.
[edit
Main article: Web browser image format support
PNG support first appeared in Internet Explorer
Despite calls by the Free Software Foundationcitation needed]
GIF
▪\tNo support on old browsers (such as Internet Explorer
▪\tNo animation, still images only (unlike GIF, though Mozilla's unofficial APNG
PNG compatible browsers include: Apple Safari
However, Internet Explorer
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
▪
[edit
PNG icons have been supported in most distributions of Linux
[edit
PNG file size can vary significantly depending on how it is encoded and compressed; this is discussed and a number of tips are given inPNG: The Definitive Guide.[22]
[edit
Compared to GIF files, a PNG file with the same information (256 colors, no ancillary chunks/metadata), compressed by a good compressor will often be smaller than GIF, though lack of agreed data sets make any controlled comparisons subjective.[22] compared to GIF's LZW, and because the added precompression layer of PNG's predictive filters take account of the 2-dimensional image structure to further compress files; as filtered data encodes differences between pixels, they will tend to cluster closer to 0, rather than being spread across all possible values, and thus be more easily compressed by DEFLATE.[22]
[edit
PNG files vary in size due to a number of factors:
color depth
Color depth can range from 1 to bits per pixel.
ancillary chunks
PNG supports much metadata—this may be useful for editing, but unnecessary for viewing, as on websites.
interlacing
As each pass of the Adam7 algorithm is separately filtered, this can increase file size.[22]
filter
As a precompression stage, each line is filtered by a predictive filter, which can change from line to line. As the ultimate DEFLATE step operates on the whole image's filtered data, one cannot optimize this row-by-row; the choice of filter for each row is thus potentially very variable, though heuristics exist.[clarification needed
compression
With additional computation, DEFLATE compressors can produce smaller files.
There is thus a filesize trade-off between high color depth, maximal metadata (including color space information, together with information that does not affect display), interlacing, and speed of compression, which all yield large files, with lower color depth, fewer or no ancillary chunks, no interlacing, and tuned but computationally intensive filtering and compression. For different purposes one will choose different trade-offs: a maximal file may be best for archiving and editing, while a stripped down file may be best for use on a website, and similarly fast but poor compression is preferred when repeatedly editing and saving a file, while slow but high compression is preferred when a file is stable: when archiving or posting. Interlacing is a trade-off: it dramatically speeds up early rendering of large files (improves latency), but may increase file size (decrease throughput) for little gain, particularly for small files.[22]
[edit
Image editing software varies in its treatment of PNGs.
Because GIF is de facto limited to 256 colors
Some versions of Adobe Photoshop
Adobe Photoshop
[edit
Various tools are available for optimizing PNG files; they do this by:
▪
▪
▪
▪
▪
▪
▪
As some tools are PNG-specific, while others only optimize DEFLATE, in general one must use a combination of 2 tools in sequence for optimal compression: one which optimizes filters (and removes ancillary chunks), and one which optimizes DEFLATE. Most commonly, OptiPNG is used for the first (non-DEFLATE) step, and either of AdvanceCOMP or PNGOUT is used for the DEFLATE step.
[edit
For removing ancillary chunks, pngcrush
pngcrush -rem gAMA -rem cHRM -rem iCCP -rem sRGB InputFile.png OutputFile.png
[edit
For optimizing filters, OptiPNG and pngcrush
[edit
AdvanceCOMP
[edit
Wrapper tools that simplify this workflow include: ImageOptim
The littleutils
The current version of IrfanView
[edit
Since icons
[edit
▪\tComparison of graphics file formats
▪\tComputer graphics
▪\tComparison of layout engines (graphics)
▪\tImage editing
▪\tImage file formats
▪\tlibpng
▪\tRelated graphics file formats
▪\tAPNG
▪\tJPEG Network Graphics
▪\tMultiple-image Network Graphics
▪\tSimilar file formats
▪\tGraphics Interchange Format
▪\tX PixMap
▪\t.svg
[edit
1.\t^ a b c "ISO/IEC 15948:2004 - Information technology -- Computer graphics and image processing -- Portable Network Graphics (PNG): Functional specification". Retrieved 2011-02-19.
2.\t^ a
3.\t^
4.\t^
5.\t^
6.\t^
7.\t^
8.\t^
9.\t^
10.\t^
11.\t^
12.\t^
13.\t^
14.\t^
15.\t^
16.\t^
17.\t^
18.\t^
19.\t^
20.\t^
21.\t^
22.\t^ a
23.\t^
24.\t^
25.\t^
26.\t^
27.\t^
28.\t^
29.\t^ a
30.\t^
31.\t^
32.\t^
33.\t^
34.\t^ a
35.\t^
36.\t^
37.\t^
38.\t^
39.\t^
40.\t^
41.\t^
42.\t^
43.\t^
[edit
▪\tRoelofs, Greg (April 1997). "Linux Gazette: History of the Portable Network Graphics (PNG) Format". Linux Journal (Specialized Systems Consultants, Inc.) 1997 (36es). ISSN 1075-3583.
▪\tRoelofs, Greg (2003). PNG: The Definitive Guide (2nd ed.). O'Reilly Media. ISBN 15659224.
[edit
[edit
▪\tPNG Home Site
▪\tlibpng Home Page
▪\tThe Story of PNG by Greg Roelofs
[edit
▪\tPNG Specification (Latest Edition)
▪\tTest inline PNG images
[edit
▪\tAn introduction to the PNG image format — Including test images, file editing tips, and reviews of PNG image tools for Windows.
▪\tRFC 2083
▪\tPNG transparency test
▪\t"The Lonely Planet" — PNG-based animation for web browsers
▪\tMore information about PNG color correction
▪\tThe GD-library to generate dynamic PNG-files with PHP
▪
▪
▪
▪
▪
[showv · d · e
∙\tLog in / create account
∙\tArticle
∙\tDiscussion
∙\tRead
∙\tEdit
∙\tView history
窗体顶端
窗体底端
∙\tMain page
∙\tContents
∙\tFeatured content
∙\tCurrent events
∙\tRandom article
∙\tDonate to Wikipedia
Interaction
∙\tHelp
∙\tAbout Wikipedia
∙\tCommunity portal
∙\tRecent changes
∙\tContact Wikipedia
Toolbox
Print/export
Languages
∙\tAfrikaans
∙\tAlemannisch
∙\tالعربية
∙\tБългарски
∙\tCatalà
∙\tČesky
∙\tDansk
∙\tDeutsch
∙\tEspañol
∙\tEsperanto
∙\tEuskara
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙
∙Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
∙
∙
∙
∙
∙
∙
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- awee.cn 版权所有 湘ICP备2023022495号-5
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务