Image
Compress Image Crop Image Resize Image QR Code Generator Image to Icon Converter
Encode/Decode
Base64 Decode/Encode MD5/SHA1/SHA-256
Formatter
JSON Formatter XML Formatter
Converter
RGB/HEX Converter Unix Timestamp Converter
Others
Word Counter World Time Hub AI Tools Hub AI Domain Name Generator
Language
English 日本 español italiano Nederlands français Português Deutsch русский العربية Tiếng Việt 简体中文 বাংলা Bahasa Indonesia Türkçe हिन्दी 한국어

Image Compression Technology

2023-08-28

Introduction

  • Reduce storage requirements — Compressed images take up less space in memory and disks. This saves storage costs.
  • Enable faster transmission — Compressed images can be sent over the internet or other networks much faster than uncompressed files. This improves transmission speed.
  • Reduce bandwidth usage — Image compression reduces bandwidth usage and stress on networks when transferring images and videos.
  • Faster processing — Compressed images can be processed and rendered more efficiently due to reduced data size.
  • Applications like digital cameras, scanning, fax etc would not be feasible without image compression. The performance of applications like multimedia sharing, video streaming etc also relies heavily on image compression.
  • As the name suggests, lossless compression techniques compress the image while retaining all of the original image information.
  • The reconstructed image after compression is numerically identical to the original image.
  • Techniques used include run-length encoding, Huffman coding, and Lempel–Ziv–Welch (LZW) compression.
  • Achieves compression ratios of around 2:1 to 4:1.
  • Used when pixel-perfect reconstruction is required, like medical imaging, technical drawings etc.
  • Lossy techniques compress the image by discarding some image data.
  • The reconstructed image is not identical and loss of quality is observable.
  • Can achieve much higher compression ratios of 10:1 to 100:1.
  • Many techniques like transforming, quantizing, fractal encoding, wavelet transform etc.
  • Used for natural images and video where small loss of quality is acceptable, like social media images.
  • JPEG and MPEG use lossy compression.

Lossless Compression Techniques

Run-length encoding — replace sequences of identical pixels with pixel count

  • In images, it is common to find sequences or runs of identical or similar pixels together.
  • The key idea behind run-length encoding (RLE) is to replace repetitions of pixels with the number of repetitions.
  • For example, instead of storing a sequence like “AAAAAAABBBCCCC”, RLE would store it as “8A3B4C”.
  • To decompress, the runs are simply expanded back to the original sequences.
  • RLE replaces the long runs with much smaller representations, saving considerable space.
  • It is most effective on images with large areas of uniform color, like simple logos, icons, etc.
  • Only good for lossless compression since the original pixel values are preserved.
  • Easy to implement and decompress, so widely used in simple image and fax formats.
  • But cannot achieve high compression on complex images, limiting its application.
  • Overall, RLE takes advantage of redundant pixel runs to achieve lightweight lossless compression in simple images. More complex techniques build on this basic idea.

Huffman coding — variable-length codewords based on frequency

  • Huffman coding is a variable-length code that uses shorter codewords for more frequent pixel values.
  • It analyzes the image and builds a frequency table of pixel values.
  • Codewords are then assigned such that common pixels get short codewords and rare pixels get longer ones.
  • For example, say “A” pixels occur 90% of the time. It may be assigned a 3-bit codeword like “010”.
  • A rare “Z” pixel may be assigned a longer 8-bit code like “11110100”.
  • To compress, each pixel is encoded with its matching Huffman code.
  • To decompress, each codeword is translated back to the original pixel value.
  • Huffman coding achieves great compression for images where pixel frequencies are skewed.
  • But it has high computational complexity for building and matching codewords.
  • PNG and TIFF image formats use Huffman coding for lossless compression.
  • When combined with other techniques like run-length encoding, better compression is achieved.
  • Overall, Huffman coding optimizes code lengths based on pixel frequency, squeezing more compression without losing data.

Lossy Compression Techniques

Transform coding (discrete cosine transform) — convert image to frequency domain, discard high frequency components

  • DCT converts an image from spatial pixel domain to frequency domain.
  • The image is split into blocks (e.g. 8x8 pixels) and DCT applied on each block.
  • DCT concentrates the image information into fewer coefficients based on frequency.
  • Most of the signal information concentrates in the low frequency DCT coefficients.
  • The high frequency coefficients have information about edges and fine details.
  • For compression, the high frequency coefficients are quantized more coarsely or discarded.
  • This eliminates high frequency components but preserves the low frequency main shapes and colors.
  • Since human eye is more sensitive to low frequency changes, the image still looks good.
  • Transform coding techniques like DCT compact the image information into fewer coefficients allowing for compression.
  • Discarding the high frequency components allows further compression but causes loss of fine details.
  • JPEG uses DCT as the main transform coding technique for lossy compression.

JPEG compression — uses DCT, quantization, and entropy encoding

  • JPEG stands for Joint Photographic Experts Group, the standards body that created the method.
  • JPEG compression technique involves 3 key steps:
  1. DCT — The image is divided into 8x8 blocks and DCT applied to convert each block to 64 frequency domain coefficients.
  2. Quantization — The DCT coefficients are quantized to reduce precision. Coarser quantization leads to more compression but more loss of quality.
  3. Entropy Encoding — The quantized values are entropy encoded using run-length encoding and Huffman coding to compress further.
  • JPEG is optimized for compressing photographic images with 24 bit color depth.
  • JPEG compression is lossy which leads to some loss of image quality and fine details.
  • JPEG works well on images with smooth color variations but causes artifacts on sharp edges.
  • Adjustable compression levels allow trading off between file size and image quality.
  • JPEG images normally use file extensions like .jpg, .jpeg indicating the compression method used.
  • JPEG is the most common lossy image compression method used online and in digital cameras.

Image Compression Standards

JPEG — Joint Photographic Experts Group standard using DCT

  • JPEG stands for Joint Photographic Experts Group, the committee that created the standard in 1992.
  • JPEG was designed for compressing full-color or gray-scale digital images of natural scenes.
  • It works well for photographs, complex graphics, and similar continuous-tone images.
  • The compression method is lossy, since some image data is discarded during compression.
  • JPEG compression is based on discrete cosine transform (DCT) coding in 8×8 pixel blocks.
  • Chroma subsampling is used to reduce color data with little perceived loss.
  • JPEG images can be compressed at different quality levels for different file size vs image quality trade-offs.
  • Useful JPEG features include progressive encoding for web, arithmetic coding, and hierarchical storage.
  • JPEG remains the most widely used lossy image compression standard for digital images and web graphics.
  • It is implemented in software libraries of most operating systems and digital camera image pipelines.
  • JPEG images use JFIF, Exif and other formats specifying compression technique details.

WebP — Google image format optimized for web, based on VP8 video codec

  • WebP is an image format developed by Google in 2010.
  • It uses lossy compression based on the VP8 video codec.
  • Can achieve better compression than JPEG and PNG with less loss in quality.
  • WebP supports both lossy and lossless compression modes.
  • Lossy WebP offers 24–34% smaller file sizes than JPEG without visible loss.
  • Lossless WebP gives around 25–35% better compression than PNG.
  • WebP has additional advantages like alpha transparency, animation support, metadata etc.
  • Supported in all major web browsers and platforms except Apple iOS.
  • Can significantly reduce image size and improve web page performance.
  • Widely used by web platforms like Facebook, Reddit, Twitter, Wikipedia etc.
  • Google recommends WebP over JPEG and PNG for delivering images on the web.
  • WebP plug-ins available to add WebP support to image editors and web servers.

Free Online Image Compression Tools