Image processing: png vs jpg: when they’re the same size….

Self-tutoring about image formats: the tutor shares a find.

In my post from June 6, I include a photo of a spider taken from my phone. I saved it both as a .png and a .jpg (aka,.jpeg), same dimensions, etc. I thought the .jpg file would be smaller (in memory) than the .png one. Interestingly, they are the same, at 55kB.

I researched how a .jpg and its corresponding .png image can be the same size. It turns out that, indeed, they can, and here’s the reasoning:

Both .png and .jpg use compression. The .png finds patterns among pixels, so compresses according to the predictability. The .jpg, on the other hand, potentially reduces the colour variety from pixel to pixel in ways the human eye may barely notice – if at all.

Therefore, just for an example, a photo entirely one single colour value might likely be compressed smaller in the .png than the .jpg format, since it’s absolutely predictable.

In its original application, .png does not allow for loss – meaning that if a pixel can’t be predicted, it’s recorded uniquely. Therefore, a .png image might need more memory than its .jpg counterpart. However, if the image processing software can find enough pattern in the image – and if the colors don’t show tremendous variety in the first place – then apparently a .png file can end up the same memory size as its corresponding .jpg – maybe even smaller!

I hope to post more about image formats:)


Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply