AlphaJPEG is a JavaScript library for the generation and consumption of JPEG images which contain extra information to obtain an alpha channel.
Though, WebP allows for superior (to JPEG) lossy compression with an alpha channel, it is not a viable image format in the modern browser landscape. Once WebP takes over, this tool will be obsolete.
This tool will allow you to perform lossy compression on an image with an alpha channel in an image format supported by all modern browsers. Anecdotally, this results in a JPEG 20-50% of the original PNG file size with very little discernible artifacts.
A source image with an alpha channel is rendered onto a white background and a black background. These two images are combined into a single JPEG image which is twice the original image's width and lacks the original image's alpha channel.
To render, the red, green, and blue channels are obtained (via averaging) from the images rendered on white and black backgrounds. The alpha channel is obtained by calculating the delta of the white and black image's green channels. The green channel is used because JPEG images have higher green channel quality than the other two, since green is the most sensitive color to the human eye.
It works on all browsers that support the canvas element.
Creation of JPEGs should work on all browsers except for Internet Explorer, due to spotty Data URI support.
Nothing! It's completely self-contained, and released under the MIT license.
See a demo here.