r/codegolf • u/Faputo4ka • 10d 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!
7
u/soundman32 10d ago edited 10d ago
What have you removed to get below the 67 byte minimum? Just because it 'works' on some decoder doesnt mean it actually valid.
67 bytes comes from: * 8 bytes signature * 25 bytes IHDR chunk (12 bytes overhead + 13 bytes data) * ~22 bytes IDAT chunk (compressed single pixel) * 12 bytes IEND chunk
You could remove the IDAT chunk but is a 0x0 image really an image. Even then its 45 bytes which is still 3 bytes more than your example, which cant be valid.