JPEG is well known standard for image compression and Discrete Cosine Transform (DCT) is the mathematical tool used by JPEG for achieving the compression. JPEG is lossy compression meaning some information is lost during the compression. Lets dig deeper into the JPEG standard starting from the block diagram.
Above diagram shows the encoder part of JPEG. The decoder is the reverse of encoder except it doesn't contains the reverse part of Quantizer block and this is the main reason why JPEG is lossy compression. We cannot recover data lost during the quantization step. The operations performed by each block is presented below