Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPEG image with alpha channel on website [closed]

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?

like image 603
Elias Zamaria Avatar asked Apr 14 '10 18:04

Elias Zamaria


People also ask

Does JPEG support an alpha channel?

The JPEG format doesn't support transparency. But we can create our own transparency using a second image as an alpha channel.

Can you have a JPEG with transparent background?

JPEG can't support transparency because it uses RGB color space. If you want transparency use a format that supports alpha values.

Which file formats does not support the alpha channel?

The GIF format does not support alpha channels.


1 Answers

Yes you can do this. The JPEG format makes provision for exchangeable image file format

  • Color space definition
  • Component sub-sampling registration
  • Pixel aspect ratio definition

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.

like image 133
martin Avatar answered Sep 20 '22 13:09

martin