Lossless means the same pixels
PNG compresses a picture without discarding anything, so a PNG made from a BMP shows exactly the same picture. We tested this instead of assuming it: nine BMP files of different kinds were converted in Chrome and compared pixel by pixel with Pillow's reading of the same files. Seven came out identical, and two (a 16 bit file and a file with partly see-through pixels) differed by at most one level out of 255.
The file shrinks because BMP stores every pixel in full while PNG predicts each pixel from its neighbours and compresses what is left. Flat areas compress to almost nothing: a 96 by 64 picture of flat shapes went from 18 KB to 386 bytes. A photograph compresses much less, and our 9.4 MB photo became 4.5 MB.
Transparency in a BMP is a special case
Most BMP files have no transparency. A 32 bit BMP stores four bytes per pixel, but the fourth is only an alpha channel when the file's header says so, in the newer header forms that include an alpha mask. MDN notes that alpha in BMP is not widely used and often not implemented at all.
We tested both cases. A file with an alpha mask kept its transparent strip and its half transparent block exactly. A file with a plain header and real values in the fourth byte was read as fully opaque: a corner that was see-through in the source came out as solid black. That is how browsers read such files, and it is the reason a transparent logo saved as a BMP is not a safe master. If the picture matters, make the PNG from the original program instead.
1, 8, 16 and 24 bit files
- 24 bit pictures keep all their colours. PNG stores them at 8 bits per channel, the same.
- 8 bit palette files stay palette pictures, so the PNG is small. A test file of 6.5 KB gave a 717 byte PNG.
- 1 bit black and white files stay 1 bit.
- 16 bit files use 5 or 6 bits per channel. The browser expands those to 8 bits when it opens them, so the PNG is a normal full colour picture with the same look.
PNG here is always 8 bits per channel. A BMP cannot hold more than that, so nothing is lost on the way.
When the PNG is still big
A PNG of a photograph is large however well it is compressed, because every pixel of detail is kept. If the BMP is a photo and you only need to share it, BMP to JPG gives a file of well under a tenth of the BMP. Use PNG for screenshots, diagrams, icons, pixel art and anything you will edit again.
Pictures above 16 megapixels skip the optimiser, so those PNG files are bigger than they could be. The list notes it when that happens.