A implementation of JPEG compression, using the discrete-cosine transform (DCT) algorithm. This algorithm leverages the fact that the human eye is less sensitive to high-frequency information; it transfers spatial information of the frequency domain, and keeps only lower-frequency in the compressed image. The exact partition of kept-vs-discarded frequency content is determined by the quantization matrix ('quant.csv'). We elected to use a quantization matrix used in standard practice, but it can be swapped for another.
This is a poor man's implementation -- it is not nearly as efficient as something you'd find on your favorite image processing software, as performance drops largely as the size of the image grows. The focus here is not performance but illustration of the different mechanisms involved and the workflow.