Why can’t JPEGS be transparent?

397 views

Why can’t JPEGS be transparent?

In: 1537

19 Answers

Anonymous 0 Comments

The modern way to encode transparency is to use 4 channels: 3 for colors (e.g. RGB or YCbCr) and 1 for degrees of translucency (the so-called alpha channel).

JPEG does not have this 4th channel. It uses [YCbCr](https://en.wikipedia.org/wiki/YCbCr).

The *old* way is to use a certain color (e.g. RGB=0,0,0, i.e. black) to be interpreted as invisible. That’s how GIFs work. Theoretically you could make a JPEG reader which does that.

GIF saves this color in its palette table, but JPEG doesn’t do that, so the reader would have to assume a certain color whether it makes sense or not. It’s not a deal breaker, though, there are some semi-reasonable ways, like checking corner pixels etc.

The biggest problem is JPEG compression blurs and replaces colors somewhat. Normally, it’s imperceptible when it replaces 0,0,1 and 0,2,0 with 0,0,0. With improvised transparency, a hole would grow or shrink when saved. Horrible.

You are viewing 1 out of 19 answers, click here to view all answers.