Advertisement


Why do people use JPG images?


Question

I see JPG images everywhere. But why?

PNG files have opacity, while JPGs do not. I've tried exporting some images to PNG and JPG to compare size, and they both either match up or the PNG is smaller(depending on the image of course).

enter image description here

This is a 512x512 JPG image that says "JPG"

enter image description here

And this is a 512x512 PNG image that says "PNG".

The JPG was 31.7kb and the PNG was 25.9kb

So what gives?

2015/06/05
1
17
6/5/2015 1:59:00 PM

Accepted Answer

Because they are way better at compressing pictures that have lots of colours and irregular shapes, like photographs.

Have you tried the same epxeriment you did, but then with a photograph? The .png is most probably going to be noticeably bigger than any .jpg, regardless of the .jpg's compression factor.

Example:

png picture
.png picture, 110k

jpeg at 100 quality
.jpg at 100% quality, 63k

jpeg at 30 quality
.jpg at 30% quality, a measly 9k

If you look closely, you will see some artefacts on the 30% quality .jpg, but that's mostly because the hard edge of the lightbulb against the smooth green background doesn't lend itself too well to the compression algorithm. You can have regular pictures reduced to even 10 or 5% quality without any loss you'd notice at a glance.

2019/01/08
35
1/8/2019 3:33:00 PM

JPEG has backing from the photographic industry and predates PNG by a half-dozen years or so, while PNG was designed as a replacement for GIF, which was rather zealously protected by CompuServe. People were sued for using GIFs on their websites, for example, simply because they didn't use a program that was licensed by CompuServe to make those images.

From the beginning, JPEG was designed to recover some space by making files smaller, at the expense of pixel-perfect quality. Even setting Q to 100 will cause minor, mostly invisible artifacts-- the damage is done, and each additional time the file is modified and saved, further damage will occur. However, unless you do so many times, you'll probably never notice the effect unless you go looking for it.

PNG, on the otherhand, is perfectly lossless. Every pixel is faithfully reproduced every time, no matter how many times the file is modified and saved. There's a limit to how well you can compress data without loss, however, although PNG employs several tricks to pack as much information into as few bytes of data as possible. A high quality JPEG will probably be about the same size a PNG without optimization or even larger. As PNG begins to optimize, say, by using filters or adjusting window sizes, the file becomes smaller without loss, while JPEG must start discarding visual information to keep up.

So, why is JPEG used? It is, after all, generally inferior in terms of fidelity and storage space. The main reason, of course, is that it is an industry standard and has very broad support. Virtually every camera in the world uses either RAW (literally, the raw data), or JPEG. There are hardware data processors built-in to those cameras to compress the JPEG data as fast as possible, etc.

You'll find this is the same reason why GIF is everywhere still. Most software supports GIF, while PNG enjoys lesser support in older software (e.g. older Internet Explorer versions required a plugin to show PNG files). Even though it has lousy color support, it does support animations, something PNG does not do (there is a related file format, APNG, that never quite took off the way PNG did). GIF still remains the champion of animated images, as it is the only file format that can do so with widespread support.

The cost to change from JPEG to PNG would be prohibitive from a hardware prospective. Cameras would need new processors built to support fast PNG compression, for example, because they're hard-coded to use JPEG right now. Your old cameras would be worthless, because you'd have to buy a new one with a PNG chip built-in. That would also mean you'd have to convince a manufacturer to go against industry standards and start manufacturing such devices, which means there'd have to be enough demand to justify it, and such cameras would initially be more expensive than their JPEG-based counterparts. It's very difficult to change an industry.

2015/06/05