I would like to make a JPEG image file with some pixels that are partially transparent or fully transparent, similar to a PNG file with an alpha channel. Is this possible? If so, how would I go about doing this?
I would like to use the image on a website. If I try to do this, would it work in any or all of the popular browsers (IE 7+, Firefox, Safari)? Assuming it is possible, will it just work, or are there any tricks or hacks required to make it work?
EDIT: Some of the replies say I can't do this. However, I found this page describing a JPEG image with transparency. Does anyone know if there is a convenient way to produce files in this format? Is it widely supported?
The JPEG format doesn't support transparency. But we can create our own transparency using a second image as an alpha channel.
JPEG can't support transparency because it uses RGB color space. If you want transparency use a format that supports alpha values.
The GIF format does not support alpha channels.
Yes you can do this. The JPEG format makes provision for exchangeable image file format
JPEG/Exif is the most common for photography and JPEG/JFIF is the most commonly used for storage.
When the others state JPEG format doesn't provide for an alpha channel all they are really saying is that there is no widely used formats for JPEG encoding that include an alpha channel.
Have a look at On adding alpha channels to JPEG images, where the author describes and provides a solution to exactly what you are trying to do and uses the the canvas element to render on a browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With