It doesn’t in actual GIFs, or PNG. Those use a kind of compression that works best on areas of a solid color. If there’s 5 white pixels in a row, rather than writing “white,white,white,white,white” you write “5 x white”. It’s also a lossless kind of compression, where the resulting image is identical to the uncompressed one.
The problem is that areas of a single color are actually pretty much nonexistent in things like photographs, and this kind of compression doesn’t work for them. So JPEG uses a different method entirely. How it works is actually quite complex and I don’t think I can make it justice in a comment, but there’s a [very good video series](https://www.youtube.com/watch?v=LFXN9PiOGtY&list=PLzH6n4zXuckoAod3z31QEST1ZaizBuNHh)
on that. Video encoding also follows similar principles.
Latest Answers