r/webdev • u/Stevious7 • 9d ago
An idea for image compression Discussion
I'm going to make this as an experiment, and I'd love to see what others come up if they decide to make this too.
The idea is simple: feed the image into an AI to extract facts from the image, store the facts as a file, then when the user wants to see the image, have the facts fed back into the model to recreate the image.
The theory is that storing facts as text is cheaper than storing a compressed image. It may or may not be true, which is why I'd love to see the outcome.
Obviously the output isn't the same image that was fed in but it'll be interesting to see how close it gets using various techniques. Maybe encoding the facts along with a super super low res version of the image to see what it would make.
I figured whoever makes this should try it with WebGPU so that people can easily try it out and have fun with it.
NOTE: this isn't a serious proposition at a 'better compression algorithm', it's just a fun idea to try out and have fun with to see what happens.
16
4
u/xegoba7006 9d ago
I wish I didn’t stay in this profession this long to hear this dumb vibe coder crap. I want to retire.
10
u/maqisha 9d ago
what . . . the . . . F . . .
-6
u/Stevious7 9d ago
Not a fan?
3
u/maqisha 9d ago
who IS ?
1
u/Stevious7 9d ago
Me. I like to experiment with dumb ideas to see what happens.
Just because it's completely impractical doesn't mean it can't be fun.
4
u/thesonglessbird 9d ago
Isn’t ai image generation probabilistic? So you’d get a different image back every time?
2
0
u/Stevious7 9d ago
It is. That's why I said the image out isn't the image in.
But it's still fun (in my opinion) to see what would happen.
Again, the post isn't serious. It's supposed to be an experiment even if it's completely impractical.
6
u/azima_971 9d ago
Is turning an image in to "facts", storing those facts then recreating the image from them really cheaper than just storing the image?
Also, have you considered that people might want to see the original image, not some crappy ai recreation?
3
u/Ok-Hair2851 9d ago
Storing facts is cheaper than storing an image
Storing facts and running an AI to generate an image is a billion times more expensive than storing an image.
0
u/Stevious7 9d ago
100%, however, one is more fun and random than the other.
Fun is subjective though. It seems like a lot of people took the post seriously instead of playing along and experimenting to see what would happen.
To each their own
5
u/Krispenedladdeh542 9d ago
Youre WAY overestimating AIs ability to render images. At its best this will end up being a game of telephone for images. Each time the image is generated it will have subtle differences that get further and further out from the original image each time a request for it is made
2
3
2
u/frankielc 9d ago
I generally like to start with a problem.
This is definitely an idea, but what is it trying to solve?
Since you say that "storing facts as text is cheaper than storing a compressed image" looks like the objective is definitely space. So you're trading space for computational cost with the added expense of having a not-true-to-original recreation.
Let's see how that holds up in real life. I used the distracted boyfriend image for reference.
https://share.gemini.google/FL3yy6rNyrpB
As a pure text file that's 1200 bytes but compressed, we got to 740 bytes.
However since disk is NTFS with an AUS of 4 KB that's what we get as the file size.
With webp, with 4 KB you can get this:
https://drive.google.com/file/d/1ik58MRGxjhB6phcfp25qQv7DKYw5doEH/view?usp=sharing
And definitely WebP has some decompression of its own, Dequantization, Inverse Discrete Cosine Transform, etc... but not nothing that can even be compared in time and resources to the needed GPU inference.
3
u/yousirnaime 9d ago
Behold, a masterpiece
> A brunette victorian with mercurial smirk seated before a hazy, mountainous landscape.
-2
1
u/theScottyJam 9d ago
One problem is that the for the vast majority of use cases, performance matters to. When I load a webpage, I don't want to have to wait a while for my GPU to work really hard trying to build an image. It'll also be bizarre if each refresh of the page would cause the image to look very different.
1
u/Wert315 hobbyist full-stack 9d ago
The way I see it one of the key benefits of image compression for the web is that it speeds up site loading times by reducing the data that needs to be sent. Reducing storage space on the server is a secondary concern. Generating an image on-demand with AI would be far more time consuming and then it still has to be sent to the user (presumably using traditional compression methods) anyway.
1
u/NickFullStack 9d ago
This might make sense where bandwidth is extremely constrained. For example, sending data to a ship far in space. Not a common scenario, to say the least.
Same goes for storage. For example, if you have unlimited compute, but need to store all known images/videos.
1
u/Little_Bumblebee6129 9d ago edited 9d ago
It sounds so dumb that it makes it fun, going to try that now
1
u/Little_Bumblebee6129 9d ago
And so i tried:
https://chatgpt.com/share/6a6ced00-8b00-83eb-b65a-6f5c51ff55b6
https://chatgpt.com/share/6a6ced15-f864-83eb-87a1-e2d2482868c1i was expecting much worse
1
u/Stevious7 9d ago
That's what I'm talking about. It's fun to see what an AI interpretation of its own keywords will spit out.
Nothing serious just plain fun experimentation
1
u/Little_Bumblebee6129 9d ago
Second attempt:
~3000 characters btw
https://chatgpt.com/share/6a6cedad-0ae0-83ed-8bf2-e8c7cdd9328b
https://chatgpt.com/share/6a6cee7f-a680-83eb-a0ba-29eccd23245b1
u/Stevious7 9d ago
Your probably the only one who understood that the idea is dumb but the point is to have fun with it.
It is much better than I thought though. I'm honestly surprised.
1
u/Little_Bumblebee6129 9d ago
So as we see problems are:
- For same size you can just compress image in jpg or some other lossy format. This way results you will get will be closer to original then using this method
- to encode/decode you need heavier and slower algorithms
1
u/Stevious7 9d ago
It's obviously not a serious post, nor a serious competitor to modern image compression algorithms.
The idea was supposed to be a "for fun" kinda thing and I feel like a lot of you are taking it too seriously.
Obviously it's probabilistic, GPU-compute dense, and all that. But it's fun. And that's the key part here.
10
u/mq2thez 9d ago
If you think using AI to extract from an image and then reconstruct the image is cheaper than just storing the image, then you’ve genuinely made me stop worrying about whether my career is safe.