A Look Inside The Smallest Possible PNG File

What’s inside a PNG file? Graphics, sure. But how is that graphic encoded? [Evan Hahn] shows you what goes into a single black pixel inside a 67-byte file. Why so many bytes? Well, that is exactly what the post is about.

You had to guess there is some overhead, right? There is an 8-byte header. Next up is a 25-byte metadata block. That single pixel takes 22 bytes, and then there is a 12-byte marker for the end of file. Turns out, you could put a bit more in the file, and would still take 67 bytes. The metadata is in a chunk — a block of data with a type, length, and CRC. That’s why it takes 25 bytes to store the dimensions of the image. A chunk has to be at least 12 bytes long. The metadata includes the image dimensions, the bit depth, and so on.

The next chunk, of course, is the data. The data is compressed, but in the case of one pixel, compression is a misnomer. There will be ten data bytes in the data chunk. That doesn’t include the 12 bytes of the chunk overhead so that one pixel takes a whopping 22 bytes.

The end of file marker is another chunk with no data. The total? 67 bytes. However, you can add more than one bit and still wind up with 67 bytes. For all the details, check out the post.

Luckily, it is easy to pronounce PNG. You can even use the format for circuit simulation.

19 thoughts on “A Look Inside The Smallest Possible PNG File

      1. Four.

        You need at least two parallel lines of different value to define an edge, which is the least amount of “detail” you can encode. Since one line consists of at least two points, the minimum number is four.

        A single pixel is not meaningful by itself without contrast to other pixels. If you only care about the 1D case, then the minimum number is two.

      2. Well the famous 1990 Pale Blue Dot image filled less than a pixel on the sensor, but the receptor still read it as pale blue. It may have been more vivid if Voyager were closer to Earth- enough to fill that single pixel.

        Considering all the proper awe and wonder generated, I would say that 1 pixel counts as an image. Though, it was in the context of the blackness of space and reflections inside of Voyager’s vidicon camera lenses. And, we had Carl Sagan’s genius assessment of the image put into such beautiful prose.

        Come to think of it, try to torrent the audiobook that came from that single pixel. It’s called “The Pale Blue Dot”.

  1. Looks like it could be an art ntf, which could sould by an gallery to a stupid collector. I can imagine when he screams: ‘lock at my grey pixel, its grey, and its huge, and it only costs 10.000 €’

    But this would restart the question, can you get a Patent on our air that we breath, or like the telekom got an trademark for the base color magenta…. Or like the american company get a patent on the real basics how a fungus works, and stopped so the innovation in rest of the world. But hey money above human life, yesterday again a Boing 737 max 9 case in the media.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.