Image compression using the DCT method
Image compression is used to reduce the size of a digital image file. This is necessary to boost speeds across the internet, as clients can download the compressed image and decode it on their device instead of downloading the larger file. That way, they can view a high quality version of the image quickly, avoiding the transfer time of uncompressed images. One of the methods by which these images are compressed is through a process called the DCT, or Discrete Cosine Transform, which we’ll be going over in this glossary.
What is DCT Compression and How Does It Work?
The Discrete Cosine Transform (DCT) is used in lossy image compression codecs such as the well-known JPEG format. The image is split into blocks (8×8 in case of JPEG), then run through an algorithm that mathematically transforms the (spatial) pixel values into frequency coefficients, which are then quantized entropy coded, and serialized into a bitstream that can be stored as a file or transmitted. On the receiving end, an algorithm is run that applies the inverse steps of this procedure and reconstructs the pixel values in all of the blocks.
Without getting into the complexities of mathematical algorithms, DCT compression has become a very widely used coding tool in image codecs such as JPEG WebP, AVIF, JPEG XL and video codecs such as H.264 and VP9. It’s a and battle-tested method, and remains to this day one of the lossy coding tools best aligned with human perception.
Image Compression with Cloudinary
Image compression is an important factor when planning to deliver media. And with Cloudinary’s media optimization, we automatically compress images using the optimal encoder for the task. Our API can encode images automatically through f_auto, using the best available codec, whether that is JPEG, WebP, AVIF or JPEG XL. Although these different codecs all use DCT compression, they differ in their other coding tools and entropy coding capabilities, which allows more modern codecs like AVIF and JPEG XL to result in higher image quality at smaller file sizes.
If you want to get a headstart on optimizing your media, try Cloudinary today. You can sign up for free today!
Additional Resources You May Find Useful: