image compression with MozJPEG: using a memory buffer instead of a file stream
MozJPEG's API is built around the concept of destination and source managers. As their respective name implies, destination and source managers tell MozJPEG where to read/write data before/after compression. The default ones are jpeg_stdio_src/jpeg_stdio_dest which read/write data from a file stream, but there is also the jpeg_mem_src/jpeg_mem_dest.