===== Overview ===== [[http://www.ijg.org/|Project web site]], libjpeg is a C library for compressing and decompressing JPEG images. ===== Case Studies ===== * On a Core 2 Duo E6300 it takes 1.5ms to compress a 160x120 RGB image, 0.6ms for 72x88, 0.06ms for 32x24. ===== Gotchas ===== * 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. ===== Tips & Tricks ===== * 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. ===== Alternatives ===== * [[http://nothings.org/stb_image.c|stb_image.c]] - a small self-contained C lib for decompressing JPEG and PNG images ===== Other Resources ==== * [[http://www.w3.org/Graphics/JPEG/|W3C's JPEG page]]