worldsbestfacts
Photograph of a computer monitor showing a pixel test pattern

Lossless

PNG compression can preserve every original pixel value.

5 min readLast updated

Photo: Hayden Schiff · CC BY 4.0

The short answer

PNG compression preserves the pixel values supplied to its encoder without throwing image information away. That makes it useful when exact image data matters more than the smallest possible file.

Why it's true

Lossless means the compression process is reversible: decoding recovers the encoded image samples exactly. Repeatedly compressing and decompressing unchanged PNG image data does not gradually introduce the block patterns or blurred edges associated with ordinary lossy JPEG encoding.

PNG is especially useful for screenshots, diagrams, interface graphics, and text because sharp boundaries and repeated colors often compress effectively. Photographs can also be stored exactly, but their complex detail commonly produces larger files than a visually acceptable JPEG.

Transparency is part of the format rather than a workaround requiring a fixed background. PNG can represent partially transparent pixels, helping software composite soft edges, shadows, and other graphics over different backgrounds without baking those backgrounds into the image.

By the numbers

1996

Initial specification

.png

Filename extension

Lossless

Compression type

The backstory

PNG emerged during the 1990s as an alternative to GIF, amid concerns about patents affecting the LZW compression used by GIF. Its initial specification appeared in 1996. The project combined an openly documented format with features useful for exchanging still images across different computer systems.

The name stands for Portable Network Graphics. Unlike a format designed mainly to reduce photographic file sizes at an acceptable visual cost, PNG was built around lossless image storage. It supports grayscale, truecolor, and indexed images, with different capabilities for color depth and transparency depending on the image type.

Its compression pipeline first filters scanline data to expose patterns that compress well. Those filters do not permanently remove visual detail: a decoder can reverse them. The filtered bytes then undergo DEFLATE compression, which exploits repetition and statistical patterns. Different filter choices and compression settings can produce different file sizes while preserving the same decoded image samples.

The wider picture

The important boundary is what enters the encoder. If an editor first reduces an image from higher precision to lower precision, changes its color space, or discards colors, saving the result as PNG cannot restore what the editor already removed. PNG compression is lossless, but a complete editing or export workflow is not automatically lossless.

Exact stored samples also do not guarantee identical appearance everywhere. Color management, display calibration, scaling, and application behavior can change how those samples look on screen. Similarly, a program may preserve the visible image while stripping metadata when it resaves a file. Pixel preservation and preservation of every original file byte are different promises.

Worth remembering

  • Choose PNG when exact image samples, clean graphic edges, or partial transparency are important requirements.
  • Compare formats for photographs rather than assuming that lossless compression will also produce the smallest download.
  • Check export settings and editing steps, because lossless file compression cannot undo earlier changes to image data.

In context

PNG, JPEG, and GIF make different promises about image data. Comparing them requires identifying the stage at which information may change. A lossless encoder preserves its input samples, but it cannot restore detail already removed by an earlier resize, palette conversion, or lossy export.

A closer look

Lossless does not mean untouched forever

A PNG can store an image after substantial editing without recording the discarded earlier version. The promise concerns recovery of the samples supplied to that PNG encoding step. This is why converting a damaged JPEG to PNG prevents a further lossy storage step but does not reverse existing artifacts. File format and editing history need to be considered separately.

Transparency is not a background color

An alpha channel describes opacity rather than merely assigning a pale or matching background. That helps graphics blend against different surroundings. However, applications still need to interpret and display the stored image correctly. Exact decoded samples and identical appearance on every screen are different claims because display behavior and color handling also influence what a viewer sees.

Related facts

JPEG explores the different tradeoff made when reducing photographic file sizes. Ordinary JPEG compression saves space by discarding image information.

GIF shows how palette choices and compression can impose different kinds of limits. A GIF image palette holds at most 256 colors.

A related history explains why the first YouTube video was filmed at a zoo. The first video ever uploaded to YouTube was 19 seconds long, at a zoo.

This companion article explores Original ASCII fits into seven bits. Original ASCII fits into seven bits.

Key terms

Lossless compression
Compression that permits exact recovery of the data supplied to the compression process.
Alpha channel
Image data describing opacity for use when compositing an image with a background.

People also ask

Does saving a JPEG as PNG restore its original detail?

No. PNG can preserve the pixels obtained by decoding that JPEG, but it cannot reconstruct information discarded during JPEG encoding. Converting may prevent additional lossy compression in later saves, yet the file will often become larger without gaining genuine detail.

Can two PNG files contain the same image but have different sizes?

Yes. Encoders can choose different filters, compression effort, and metadata. These choices can change the stored bytes and file size without changing decoded pixel values. A smaller PNG is therefore not necessarily a lower quality image.

Is PNG always the best format for web images?

No. It is a strong choice for some graphics and transparency needs, but modern alternatives may deliver suitable quality at smaller sizes. The right decision depends on the image, browser support, editing requirements, and whether exact reconstruction is necessary.

Does converting JPEG to PNG recover lost detail?

No. PNG can preserve the already decoded image without a new lossy encoding step, but it cannot reconstruct information discarded earlier.

Can two PNG files differ in size yet decode to the same image?

Yes. Compression and filtering choices can change the stored representation while preserving the decoded sample values.

Sources

Send this to someone

More like this

See all

Join the list.

Every now and then we'll send you a fact you've never heard before.

No spam. No set schedule. Unsubscribe anytime.