Project web site, libjpeg is a C library for compressing and decompressing JPEG images.
Has a rather weird OO-style system implemented in C for customizing the behaviour.
The default compressor and decompressor work only for file descriptors, to do in-memory you need to write 5-6 functions of your own.
Read the documentation and the example code that comes with libjpeg, you're going to need it.
When compressing, you can pass in an array of pointers to the same string as the scanlines array, so there's no need to copy data.
If you use setjmp/longjmp in your error handler, you can add the jump target to cinfo→client_data.
stb_image.c - a small self-contained C lib for decompressing
JPEG and
PNG images