r/AskComputerScience • u/Faputo4ka • 2d ago
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!
2
u/dmazzoni 2d ago
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.
1
u/Faputo4ka 1d ago
I wrote that I was looking for a valid png not in the opinion of everything, but only to open on the PC as a default picture and understand that there are pixels there. Here's my file 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 01 00 00 00 01 08 00 00 00 00 3a 7e 9b 55 00 00 00 01 49 44 41 54 ff
10
u/TwillAffirmer 2d ago
Why would you post this without saying what your 42 byte png is or what methods you used?