What is PNG?
.png · image/png
PNG (Portable Network Graphics) is a lossless image format supporting transparency, widely used for web graphics, screenshots, and digital artwork.
Overview
PNG (Portable Network Graphics) is a raster image format that uses lossless compression, meaning no image quality is lost during compression. It was created as a free, open-source alternative to GIF after the LZW compression patent controversy. PNG supports full-color images (24-bit RGB or 32-bit RGBA with alpha transparency), grayscale, and indexed color. It's the preferred format for web graphics requiring transparency, screenshots, and any image where quality preservation is essential.
History
PNG was developed in 1995-1996 by a group of developers led by Thomas Boutell as a patent-free replacement for GIF. Version 1.0 was published as an RFC in 1996 and became a W3C Recommendation. PNG became an ISO standard (ISO/IEC 15948) in 2004. The format gained widespread adoption as browsers added support, and it's now one of the most commonly used image formats on the web alongside JPEG and WebP.
File Structure
A PNG file begins with an 8-byte signature, followed by a series of chunks. Each chunk has a length, type code, data, and CRC checksum. Critical chunks include IHDR (image header with dimensions and color type), IDAT (compressed image data using DEFLATE), and IEND (end marker). Optional chunks include tEXt (text metadata), gAMA (gamma), and tRNs (transparency for indexed color).
Common Use Cases
- Web graphics with transparency
- Screenshots and screen captures
- Digital artwork and illustrations
- Logos and icons
- UI/UX design assets
- Technical diagrams and charts
- Game sprites and textures
- Print graphics requiring lossless quality
Advantages
- Lossless compression preserves quality
- Full alpha transparency support
- Wide browser and software support
- Patent-free and open standard
- Good for graphics with sharp edges/text
- Supports metadata and color profiles
Disadvantages
- Larger file sizes than JPEG for photos
- No animation support (use APNG or GIF)
- Not ideal for photographs (use JPEG/WebP)
- No CMYK color space support
- Slower to encode than JPEG
- Being superseded by WebP/AVIF for web use
Frequently Asked Questions
What is a PNG file?
A PNG (Portable Network Graphics) file is a raster image format that uses lossless compression. It supports transparency (alpha channel) and is widely used for web graphics, screenshots, logos, and any image where quality preservation is important.
When should I use PNG vs JPEG?
Use PNG for images with transparency, text, sharp edges, logos, screenshots, and graphics. Use JPEG for photographs and complex images where smaller file size matters more than perfect quality. PNG is lossless; JPEG is lossy.
Can PNG files have transparent backgrounds?
Yes, PNG supports full alpha transparency with 256 levels of opacity per pixel. This makes it ideal for logos, icons, and overlay graphics that need to blend with different backgrounds.
Is PNG or WebP better for the web?
WebP generally produces smaller files than PNG with similar quality and also supports transparency. However, PNG has wider legacy browser support. For modern web development, WebP or AVIF are preferred, with PNG as a fallback.
Technical Details
- Extension
- .png
- MIME Type
- image/png
- Magic Bytes
- 89 50 4E 47 0D 0A 1A 0A
- Encoding
- DEFLATE compression
- Compression
- Lossless (zlib/DEFLATE)
- Specification
- ISO/IEC 15948:2004 / W3C PNG Spec
- Max Size
- 2^31 - 1 pixels per dimension