1 Fundamentals

Image compression is the reduction of the storage or transmission cost of an image by representing its content more compactly. A compressed image aims to preserve the information that matters for a given purpose while removing unnecessary data, either exactly or approximately. The field combines ideas from signal processing, information theory, and visual perception.

1.1 Purpose of image compression

The main purpose of image compression is to reduce file size. Smaller files take less storage space, load more quickly, and require less bandwidth for transfer. Compression is therefore important in web publishing, mobile applications, digital cameras, document systems, and archives. In many workflows, efficient compression also improves responsiveness and lowers power consumption.

1.2 Types of compression

Image compression is generally divided into lossless and lossy methods. The choice depends on whether exact reconstruction is required and how much quality loss can be tolerated. Some formats and workflows support both approaches.

1.2.1 Lossless compression

Lossless compression preserves every bit of the original image data. After decompression, the image is identical to the source. This approach is used when precision matters, such as for graphics, text-heavy images, scientific data, and archival masters. Lossless methods usually achieve moderate compression rather than very large reductions.

1.2.2 Lossy compression

Lossy compression removes information that is considered less important, especially details that are difficult for human viewers to notice. It can produce much smaller files than lossless methods, but the decompressed image is only an approximation of the original. Lossy compression is common in photography, online delivery, and consumer imaging.

1.3 Compression metrics

Compression performance is commonly described using several metrics. These measures help compare algorithms and formats, although no single number fully captures visual quality or practical usefulness.

1.3.1 Compression ratio

Compression ratio compares the size of the original image with the compressed version. Higher ratios indicate greater size reduction. In practice, this measure is influenced by image content, color depth, and the specific encoder settings used.

1.3.2 Bits per pixel

Bits per pixel expresses how many bits are used on average to represent each pixel after compression. It is a useful technical measure because it relates the file size to image dimensions. Lower values usually indicate stronger compression, though not necessarily better quality.

1.3.3 Visual quality

Visual quality refers to how closely the compressed image resembles the source as perceived by a viewer. It is often assessed subjectively, but objective metrics may also be used. For lossy compression, the best settings depend on the intended use, since acceptable quality varies across tasks and display conditions.

2 Theory and principles

Image compression relies on the fact that images contain patterns, repeated structures, and perceptually less important details. By analyzing these characteristics, encoders can represent image data more efficiently. Many modern methods combine several principles in sequence.

2.1 Redundancy in images

Redundancy is the presence of more data than is strictly needed to describe the visible content. Compression methods seek to reduce this redundancy without harming the useful information. Different kinds of redundancy can be exploited in different ways.

2.1.1 Spatial redundancy

Spatial redundancy comes from the similarity between neighboring pixels. In many images, nearby areas vary gradually rather than randomly. Predictive and transform-based methods use this regularity to encode differences instead of absolute values.

2.1.2 Statistical redundancy

Statistical redundancy arises when some values occur more often than others. For example, certain colors, patterns, or prediction errors may appear repeatedly. Entropy coding techniques use these frequency differences to assign shorter codes to more common symbols.

2.1.3 Perceptual redundancy

Perceptual redundancy refers to image information that the human visual system is less sensitive to, such as very fine detail or subtle color variation. Lossy compression often removes or reduces these components because their absence may not be easily noticed in ordinary viewing.

2.2 Sampling and quantization

Sampling converts a continuous image into discrete pixels, while quantization maps numeric values to a limited set of levels. Quantization reduces precision and is a major source of data reduction in lossy compression. Fewer levels generally mean smaller files, but also greater risk of visible error.

2.3 Transform coding

Transform coding changes image data from one representation to another that is easier to compress. Instead of working directly with pixel values, it often separates significant structures from less important ones. The transformed data can then be quantized and entropy-coded more efficiently.

2.3.1 Discrete cosine transform

The discrete cosine transform is widely used in image compression because it concentrates much of the signal energy into a small number of coefficients. Smooth areas tend to produce strong low-frequency values, while fine detail appears in higher frequencies. After quantization, many coefficients may become zero or near-zero, making encoding more efficient.

2.3.2 Wavelet transform

Wavelet transforms represent an image at multiple scales. They can describe both broad structures and local detail in a compact way. Wavelet-based methods are especially useful when progressive refinement or strong compression of large images is desired.

2.4 Entropy coding

Entropy coding is the final stage in many compression systems. It encodes symbols using variable-length bit patterns based on their probabilities. Common symbols receive shorter codes, reducing the average number of bits needed.

2.4.1 Huffman coding

Huffman coding assigns shorter codes to more frequent symbols and longer codes to less frequent ones. It is simple, fast, and widely used in data compression. Its efficiency is good, though it cannot always match the theoretical optimum for a given symbol distribution.

2.4.2 Arithmetic coding

Arithmetic coding represents a sequence of symbols as a single number within a probability interval. It can achieve compression closer to theoretical limits than many simpler methods. Its implementation is more complex, and it is often used where maximum efficiency is valued.

3 Lossless image compression

Lossless image compression is used when exact recovery of the original image is required. It is common for graphics, logos, screenshots, technical diagrams, and source images that may be edited repeatedly. These methods often rely on prediction, repetition detection, or structured coding.

3.1 Predictive coding

Predictive coding estimates a pixel from nearby pixels and stores the difference between the prediction and the actual value. Because neighboring pixels are often similar, the differences are usually small and easier to compress. This approach is effective for smooth areas and images with regular structure.

3.2 Run-length encoding

Run-length encoding compresses sequences of repeated values by storing the value once together with its length. It works well for images with large uniform regions, such as line art or simple icons. Its effectiveness is limited when pixel values change frequently.

3.3 Dictionary-based methods

Dictionary-based methods identify repeated patterns and replace them with references to a stored table of sequences. This can be helpful when the same colors or pixel arrangements recur many times. The technique is conceptually simple and can produce useful savings on structured images.

3.4 Common lossless formats

Lossless formats are chosen for preservation, editing, and graphics where fidelity is essential. They may also support metadata and transparency. Some formats are optimized for specific image types or legacy workflows.

3.4.1 PNG

PNG is a widely used lossless format that supports transparency and efficient compression for graphics, screenshots, and images with sharp edges. It is especially effective for images with flat colors, text, and repeated patterns. PNG is common on the web because it balances compatibility and quality.

3.4.2 GIF

GIF is an older format known for simple animations and limited-color images. Its compression is lossless within a palette restricted to 256 colors. Because of that limit, GIF is best suited to small graphics rather than photographs.

3.4.3 TIFF

TIFF is a flexible container format often used in professional imaging and archiving. It can store uncompressed data or use lossless compression schemes. Its broad feature set makes it useful in print, scanning, and preservation workflows.

4 Lossy image compression

Lossy image compression reduces file size by discarding information that is unlikely to be noticed in normal viewing. It is the dominant choice for photographic images on the web and in consumer devices. Good lossy compression seeks a balance between compactness and acceptable appearance.

4.1 Block-based compression

Block-based compression divides an image into small regions and processes them separately. This approach makes coding simpler and can improve efficiency, but it may also create visible boundaries between blocks at low quality settings. Many popular lossy formats use block-oriented pipelines.

4.2 Chroma subsampling

Chroma subsampling reduces the resolution of color information while preserving more detail in brightness. Since the eye is generally more sensitive to luminance than to chrominance, this can shrink file size with limited visible impact. It is common in photographic compression and video systems.

4.3 Quantization

Quantization is the step that deliberately reduces precision in image coefficients or pixel values. It is central to lossy compression because it removes subtle distinctions that contribute relatively little to perceived quality. Stronger quantization yields smaller files but increases the chance of artifacts.

4.4 Psychovisual optimization

Psychovisual optimization uses knowledge of human vision to allocate bits where they matter most. Encoders may preserve edges, faces, or high-contrast detail more carefully than smooth regions. These strategies improve perceived quality at a given file size.

4.5 Common lossy formats

Lossy formats are selected when small size and efficient delivery are more important than exact reproduction. They vary in compression efficiency, compatibility, and support for transparency or animation. Format choice often depends on the delivery platform and the image content.

4.5.1 JPEG

JPEG is one of the most widely used lossy image formats for photographs. It offers strong compression and broad compatibility. Its block-based design can cause visible artifacts at high compression, especially in sharp-edged or high-contrast images.

4.5.2 WebP

WebP is a modern format designed for efficient web delivery. It supports both lossy and lossless compression, and it can reduce file size compared with older formats in many cases. Its adoption has grown because it combines practical compression with broad browser support.

4.5.3 AVIF

AVIF is a newer image format based on advanced video coding technology. It is known for high compression efficiency and support for features such as high dynamic range and transparency. Encoding can be slower than older formats, but the savings in file size can be substantial.

5 File formats and standards

Image compression is closely tied to file formats and technical standards. A format defines how image data, metadata, and color information are stored, while standards promote interoperability between software and devices. Good format design helps ensure that compressed images remain usable across systems.

5.1 Raster image formats

Raster image formats store images as pixel grids rather than mathematical descriptions. Most compressed image files are raster-based, since pixels are the natural unit for display and scanning. Format choice affects support for compression, transparency, animation, metadata, and color management.

5.2 Metadata handling

Metadata can include information such as creation date, camera settings, author details, and orientation. Some compression workflows preserve metadata fully, while others may strip it to reduce size. Careful handling of metadata is important in photography, publishing, and archiving.

5.3 Color spaces and profiles

Color spaces define how numeric values correspond to visible colors. Compression systems may convert among color models to improve efficiency or compatibility. Accurate color handling is especially important when images move between devices and software with different display characteristics.

5.3.1 RGB

RGB represents color using red, green, and blue components. It is common in digital imaging and display systems. Many images are stored or edited in RGB because it matches how screens create color.

5.3.2 YCbCr

YCbCr separates brightness from color differences. This makes it useful for compression because the color channels can often be reduced more aggressively than the luminance channel. It is widely used in lossy image and video coding.

5.3.3 ICC profiles

ICC profiles describe how a device or file interprets color. They help maintain consistent appearance across cameras, monitors, printers, and software. Including profiles can increase file size slightly, but it improves color accuracy in many professional workflows.

6 Performance and quality trade-offs

Compression is always a balance between file size, computational cost, and image fidelity. The best trade-off depends on the purpose of the image and the expectations of the viewer. Different applications prioritize different combinations of speed, quality, and storage efficiency.

6.1 File size versus image fidelity

Smaller files are easier to store and deliver, but reducing size too much can damage important details. In photography, mild losses may be acceptable if the image remains natural-looking. In technical or archival contexts, preserving fidelity may be more important than achieving maximum compression.

6.2 Compression artifacts

Compression artifacts are visible distortions introduced by an encoding process. They are often the result of strong quantization, subsampling, or block processing. Their severity depends on image content, viewing size, and the chosen compression settings.

6.2.1 Blocking

Blocking appears as visible square boundaries, especially in block-based codecs at low bit rates. It is most noticeable in smooth regions or around sharp transitions. Higher quality settings usually reduce blocking.

6.2.2 Blurring

Blurring reduces edge sharpness and fine detail. It often occurs when high-frequency information is heavily compressed or removed. Some blur may be tolerated if it helps preserve overall smoothness and reduces other artifacts.

6.2.3 Ringing

Ringing shows up as faint halos or oscillating edges near sharp transitions. It is associated with transform-based compression and aggressive quantization. The artifact can be distracting in images with text, outlines, or geometric shapes.

6.3 Use-case optimization

Optimal compression depends on the image’s role. A thumbnail may prioritize small size, while a product photo may require richer detail. Archives often favor lossless preservation, whereas social platforms and websites may favor efficient delivery and acceptable visual appearance.

7 Applications

Image compression is used in nearly every area where digital images are stored or transmitted. Its practical importance comes from the large number of images handled by modern systems and the need to balance quality with efficiency. Different sectors use different formats and settings.

7.1 Web and mobile optimization

Web pages and mobile apps rely on compressed images to reduce loading times and data usage. Efficient compression improves user experience, especially on slow connections or limited devices. Responsive delivery often involves selecting different sizes or qualities for different screens.

7.2 Photography and archiving

Photography workflows often combine compressed working files with high-quality archival copies. Compression helps manage storage demands while retaining enough detail for editing and distribution. Archival use tends to favor formats that preserve original content and metadata reliably.

7.3 Social media and messaging

Social platforms and messaging services use image compression to handle large volumes of user-generated content efficiently. Images are frequently recompressed to meet platform requirements and reduce server load. This can alter file quality, color appearance, and metadata.

7.4 Scientific and medical imaging

Scientific and medical imaging may require lossless compression or carefully controlled lossy compression. Accuracy is important because image details can influence measurement, analysis, or diagnosis. Compression choices in these fields are often constrained by technical standards and professional practice.

8 Techniques and tools

Image compression is carried out through software tools ranging from simple editors to specialized encoders. Users may compress a single image manually or automate the process for large collections. Tool selection depends on desired format, quality settings, and workflow requirements.

8.1 Image optimization software

Image optimization software helps reduce file sizes while preserving acceptable appearance. Such tools often provide previews, quality sliders, and format conversion features. They are useful for web publishing, batch cleanup, and general media preparation.

8.2 Command-line encoders

Command-line encoders provide direct control over compression settings and are common in technical workflows. They are suited to automation, scripting, and repeatable processing. Advanced users often prefer them when precise control over output is needed.

8.3 Batch processing workflows

Batch processing applies compression settings to many images at once. This is useful in large collections, production pipelines, and archival projects. Automated workflows save time and help enforce consistent output standards.

8.4 Adaptive compression strategies

Adaptive compression strategies adjust settings according to image content or intended use. For example, a smooth illustration may be treated differently from a detailed photograph. Such approaches can improve efficiency by matching the codec behavior to the image’s characteristics.

9 History and development

The development of image compression has progressed from simple pattern-reduction methods to sophisticated standardized codecs. Improvements in processing power, storage, and network infrastructure have continually shaped the field. As a result, compression methods have become both more efficient and more specialized.

9.1 Early image coding methods

Early image coding methods relied on basic ideas such as run-length encoding and simple predictive schemes. These techniques were well suited to limited hardware and low-resolution graphics. They established many of the principles later used in more advanced systems.

9.2 Standardization of JPEG and PNG

JPEG became a major standard for photographic compression, while PNG emerged as a robust lossless alternative for graphics and web use. Standardization helped ensure broad software support and predictable behavior across platforms. These formats became foundational in digital imaging.

9.3 Modern high-efficiency codecs

Modern codecs aim to improve compression efficiency while supporting features such as transparency, animation, and better color handling. They often build on advanced transform methods and refined entropy coding. Their development reflects the continuing demand for smaller files without unacceptable quality loss.

Image compression is connected to several neighboring fields that share methods or goals. These areas include reconstruction of degraded images, compression of moving pictures, and general techniques for reducing data size. Understanding these relationships helps place image compression in a broader technical context.

10.1 Image restoration

Image restoration focuses on improving images that are blurred, noisy, or otherwise degraded. While compression intentionally removes data, restoration attempts to recover or approximate lost detail. The two fields often overlap in their use of filtering and statistical models.

10.2 Video compression

Video compression extends many image-compression ideas to sequences of frames. It adds temporal prediction, motion handling, and frame interdependence. Many still-image techniques, including transform coding and entropy coding, also appear in video systems.

10.3 Data compression

Data compression is the general field concerned with representing information using fewer bits. Image compression is a specialized branch that must account for visual perception and two-dimensional structure. Methods from general compression theory, such as entropy coding, are widely reused in image codecs.