News for hackers. Stuff that matters.
Re:All 16,777,216 RGB colours (2005) by alex_smart on Saturday September 25, 2021 @02:30PM (#28655140)
Both PNG and JPG use compression (lossless in case of PNG, lossy in case of JPG) to store the image.

Now your question is basically reduced to "how can text files with same number of bytes, each having ALL the ascii codes, compress to files of such different size". The answer is that it MUST necessarily be so. You can't have a one-to-one map from [2]^N to [2]^K where K < N.

Re:All 16,777,216 RGB colours (2005) by thaumasiotes on Saturday September 25, 2021 @06:44PM (#28656815)
> The answer is that it MUST necessarily be so. You can't have a one-to-one map from [2]^N to [2]^K where K < N.

Except that you've already noted that JPG is a lossy compression scheme, so it doesn't matter that a one-to-one map isn't possible.