Saturday, July 27, 2019

png - Why do people use JPG images?



I see JPG images everywhere. But why?


PNG files have opacity, while JPGs do not. I've tried exporting some images to PNG and JPG to compare size, and they both either match up or the PNG is smaller(depending on the image of course).


enter image description here


This is a 512x512 JPG image that says "JPG"


enter image description here


And this is a 512x512 PNG image that says "PNG".


The JPG was 31.7kb and the PNG was 25.9kb


So what gives?



Answer



Because they are way better at compressing pictures that have lots of colours and irregular shapes, like photographs.



Have you tried the same epxeriment you did, but then with a photograph? The .png is most probably going to be noticeably bigger than any .jpg, regardless of the .jpg's compression factor.


Example:


png picture
.png picture, 110k


jpeg at 100 quality
.jpg at 100% quality, 63k


jpeg at 30 quality
.jpg at 30% quality, a measly 9k


If you look closely, you will see some artefacts on the 30% quality .jpg, but that's mostly because the hard edge of the lightbulb against the smooth green background doesn't lend itself too well to the compression algorithm. You can have regular pictures reduced to even 10 or 5% quality without any loss you'd notice at a glance.


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...