I would like to join the libjpeg discussion list to recommend adding a color conversion which is missing from the current implementation.
We are seeing increasing use of 32 bit RGBA images on the internet, and JPEG is the *only* popular file format which does not support RGBA, even though the specification easily allows this.
Why is this? There is really no reason why JPEG should not support RGBA, because it already has a compatible format, namely YCCK.
In the current libjpeg implementation, when a 4 channel RGBA image is supplied to the encoder, it throws away the 4th channel (A) and only saves the RGB channels as YCC, which loses data. Instead, it should save as YCCK, where K is the data from the 4th channel. In addition, the color profile would be saved as RGB so the decoder does not mistake this file as CMYK (which is the only current use for YCCK).
A simple RGBA to YCCK color space conversion is all that's needed. This is identical to RGB to YCC, except it also copies the A channel to K.
In the decoder, when a YCCK image is loaded with a RGB profile, if a 4 channel destination buffer is supplied, the K channel would be preserved by copying it to the destination.
With this simple addition, JPEG will finally support full 32 bit RGBA images, making it more useful in applications requiring transparency such as web browsers, games, mobile apps, and so on.