Why can’t JPEGS be transparent?

397 views

Why can’t JPEGS be transparent?

In: 1537

19 Answers

Anonymous 0 Comments

I’m on text to speech so there may be a lot of typos in this.

To have transparency you have to encode the data in the image. So for example let’s start with bitmap, the bitmap file format assigns a full length number to each pixel you see in an image. And this the number people are most familiar with, like the color azure is “007FFF”. And what you’re seeing in that display is the first two digits are an encoded value of 0 to 255 to represent a red scale, followed by blue and then green scale. I hope you’re with me so far, let’s move to the format known as GIF.

This format doesn’t assign a *full* number for each pixel but part of one in order to reduce file size since each frame of animation is saved as another full image. So instead each pixel can only be one of 256 different values with the first 255 are reserved for a color palette. And the 256th one is a 100% transparent pixel.

Moving to the PNG format they use a longer number to encode values. You have the same red, blue, green color scale seen in bitmap but now you have an extra two digits that track transparency. This allows you to set transparency from 0~100% on each pixel and te extra information creates a larger file size.

But the jpg format does not save individualized pixels. It is designed to compress an image down for very small bandwidth transmission back in the early stages of the internet. So rather than saving an image pixel by pixel it actually saves a couple things into a few very small algorithms allowing it to use less space than bitmap.

Trying to keep this a little less detailed it basically saves a gray scaled image called luminous and then it saves two more images, one red scaled and one blue, reduced down to a quarter of the original size. Sectors are created and colors are blended together then ran through some mathematical processes to reduce their size even more. Every single time a JPEG is loaded this process is repeated in the reverse, unpacking the image rescaling back up. The process can even be set up to display a lower resolution image while the rest of its data is still being downloaded because you can send it complicated math problems instead of streaming pixels from top left to right and then down one row to repeat. And because this process rounds out colors you can get a lot of stray pixels. Those hard to read images on Facebook and such are a great example of this format’s weakness.

So going back to transparency in jpg. The base format just does not support it. You would have to tweak every algorithm it uses at every step, and to be honest the image quality of jpg wouldn’t benefit from transparency anyway which is why people use png instead. But the good news is there is a jpg format designed to support transparency and reduce some of the stray pixels. It’s design is mostly finalized but web browsers haven’t started pick up the format yet (if you were around for it, think Blueray vs HDDVD). In a few years it may become a standard format.

Edit – I finally got around to correcting some typos. It’s still long winded and probably a bit to detailed. Again sorry for the text to speech deal and I hope you got something out of this.

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