r/AskComputerScience • u/EvidenceVarious6526 • Mar 30 '25
50% lossless compression of Jpegs
So if someone were to create a way to compress jpegs with 50% compression, would that be worth any money?
0
Upvotes
12
u/SirTwitchALot Mar 30 '25
Jpeg is lossy compression. If you think you've discovered a new algorithm that can compress them further, no you haven't.
If you really think you have, submit a paper for peer review, because there are some mathematical proofs that put an upper limit on the amount you can compress data without loss.
2
u/AlexTaradov Mar 30 '25 edited Mar 30 '25
It would be interesting technically, but would be really hard to monetize. Once you patent stuff, people will lose interest in implementing your stuff in the products unless there are no options. And there are very few scenarios where smaller images are a real necessity.
JPEG 2000 / XL are covered by patents, and even though there is some free licensing for those patents, those are not real guarantees, so nobody bothers to implement that.
And yeah, if you are somehow compressing actual binary JPEG data 50%, you are likely not calculating something correctly. If your method relies on the image data, then it is still suspicious.
5
u/ghjm MSCS, CS Pro (20+) Mar 30 '25
It is not possible to compress JPEGs, or anything else, without some of them getting bigger instead of smaller. The only thing you can do is identify statistical patterns and do more good than harm most of the time.
To understand why, thing about compressing a number from 1 to 4. To compress this 50%, you need to represent it as a number from 1 to 2. But obviously, you can't. You could represent 1 as 1, which saves 50%, but then you've got three more numbers to represent. So maybe you say 1=1, 2=21, 3=221 and 4=2221. Now sometimes you've doubled the size. It's only actually better for 1s.
But what if you know that 90% of your data is 1s? In this case, this compression scheme actually helps. But as soon as you try to compress something that doesn't follow this statistical rule, the scheme blows up.
The related math concept is the "pigeonhole principle," which is worth reading about if you don't already know it.
1
u/Ragingman2 Mar 30 '25
The jpeg standard already has different compression settings that can be used. To get a jpeg that is 50% smaller just change the quality parameter. Here is an article about it https://www.lenspiration.com/2020/07/what-quality-setting-should-i-use-for-jpg-photos/?srsltid=AfmBOooq_lKyor1QVu6_a5dkZdh34tVN06Rq3bgp6SoUi5v-xPPE-YR6
1
u/mcilrain Mar 30 '25
If.
1
u/rivervibe Mar 30 '25
Possible only if input JPEGs were poorly compressed. Compare with high compression ratio algorithms, like MozJPEG or Jpegli or Guetzli.
1
u/two_three_five_eigth Mar 31 '25
Some images you likely can compress by 50% with no data loss. You won’t be able to do that across the board, because you need to compress pixel art, photos of real people, and everything in between.
JPEG exploits the fact that most images have a lot of related colors that make up most of it.
Is it worth money? Probably not. People want to share images. If they have to pay they’ll find a free alternative like JPEG.
1
u/theobromus Mar 31 '25
It is in fact possible to losslessly recompress JPEGs using newer compression techniques (although the benefit is only about 22% rather than 50%): https://github.com/google/brunsli
Certainly improvements to that could be worth something, although there are many tradeoffs in compression (e.g. how much compute do you need to compress/decompress).
In practice, it only makes sense to use something like brunsli if you *have* to keep the original JPEG bytes. If you just want a similar quality image at a smaller size, you can use a different algorithm (like webp or avif).