The way that JPEG works. Your going from an uncompressed format to a compressed format.
How JPEG Works
"Downsampling is simply the process of reducing the chroma values by
some factor (and therefore is the first step in losing information).
In the JPEG format, there are three accepted possibilities: no
downsampling at all, dividing the chroma values horizontally by two,
or dividing the chroma values both horizontally or vertically by two.
The next step is to split the downsampled pixels in the image into 8 x
8 blocks. Each colour component is split up separately, and each
component sample goes through the same process in what follows. Note
that on many occasions, the size of the image will not be a simple
multiple of eight pixels in either direction. This can result in some
pixel artefacts being created along the right and bottom sides of a
The next step is fun, but puzzling. Each 8 x 8 block is converted into
another matrix using a Discrete Cosine Transform (DCT). This
transform, which is similar to a Fourier transform, analyses the
frequencies of the original values along each row and column using a
set of cosine waves oscillating at different frequencies and
amplitudes. The reason for doing this is that the higher frequencies
can be minimized or zeroed out since we do not perceive their loss as
acutely as the more energetic lower frequencies.
This converted matrix is then quantised. This is the main lossy part
of the algorithm and the stage where we minimise the higher
frequencies over the lower frequencies. One major result of this
quantisation is that many higher DCT coefficients are zeroed out,
making them extremely compressible in the next step.
The quantisation is accomplished by a set of 8 x 8 matrices, each one
representing a different 'quality factor' for the JPEG image. Each
cell is divided by the corresponding cell in the quantisation matrix
and the result rounded (another lossy operation). Note that this does
not involve matrix multiplication in the mathematical sense of the
Finally, the resulting quantised matrix is encoded using Huffman
compression. To make the most use of the way the values in the matrix
seem to radiate out from the top-left corner, the values are encoded
not across each row for all rows but in a zig-zag pattern. This means
that the zero cells tend to appear at the end of the zig-zag chain and
therefore can be ruthlessly compressed (in fact, there's a special
code that indicates that all remaining cell values are zero in the 8 x