r/AskComputerScience • u/Faputo4ka • Aug 30 '26
minimal size .png file
Hey everyone!
For the past few days, I’ve been obsessed with a single question: How small can a valid PNG file possibly get while still being natively readable by a PC (specifically, opening properly in the standard Windows photo viewer/gallery)?
I started by trying to make a lightweight 512x512 file, eventually managing to shrink it down to 111 bytes. After that, I started playing around with compression levels and various patterns, even managing to generate some basic procedural textures in PNG format that weighed roughly the same.
Then I decided to go deeper and chase the absolute minimum file size. At first, I hit a wall at 67 bytes—an article I read online claimed that was the lowest possible size for a functional PNG. But I kept experimenting and eventually pushed past it down to 55 bytes, and finally all the way to 42 bytes.
My current record is a fully working 42-byte PNG. It opens without issues on Windows and can be sent across messaging apps where it renders properly as an image.
However, I've hit a hard brick wall here. Every single attempt to strip away even one more byte results in an invalid file or completely breaks the structure.
My question is: Does anyone have any radical ideas, unconventional compression tricks, or deep spec-hacking methods to squeeze it down even further? I'm open to any crazy suggestions!
10
u/TwillAffirmer Aug 30 '26
Why would you post this without saying what your 42 byte png is or what methods you used?
2
u/dmazzoni Aug 30 '26
I think the limit of 67 is what the spec technically allows.
Honestly what I’d do is treat it as an attack on a specific engine like libpng. Find an input that it accepts whether it’s legal or not.
Libfuzzer might be worth exploring. It permutes inputs and instruments the code to determine if any input results in going down different codepaths.