5 ms·
Partly because PNG is lossless, but also largely because that's not the kind of image that PNG compresses well. JPEG is a better format (than PNG) to use for p
by samdk 16y ago
Partly because PNG is lossless, but also largely because that's not the kind of image that PNG compresses well.
JPEG is a better format (than PNG) to use for photos and similar types of images, because it does an okay job of compressing them and because the compression artifacts are a lot less noticeable. However, JPEG is a really bad format for things like graphics with lots of flat colors or text, because there the compression artifacts are very easy to see. This image from Wikipedia comparing the two shows the difference: http://en.wikipedia.org/wiki/File:Comparison_of_JPEG_and_PNG.png http://en.wikipedia.org/wiki/File:Comparison_of_JPEG_and_PNG...
PNG has the advantage of being lossless, and so it performs very well in some situations, but very poorly in others. Photos and images like them are an example of where PNG compresses poorly, because the . PNG actually does outperform JPEG (compression-wise) on some kinds of images though: those with lots of flat colors/text/gradients/etc., and those conveniently end up being the kinds of images where compression artifacts are really visible.
tl;dr: Use the right format for the job. PNG is not good at compressing photo-like images, but does really well at things like diagrams and vector graphics. JPEG is best-used for things like photos where compression artifacts aren't a huge deal.
If you're looking to learn more about how JPEG and PNG compress images, I recommend checking out Smashing Magazine's guides to JPEG and PNG optimization techniques. (I don't usually recommend Smashing Mag articles, but these are both good.) Both will give you some insight into how these things work.
http://www.smashingmagazine.com/2009/07/01/clever-jpeg-optimization-techniques/ http://www.smashingmagazine.com/2009/07/01/clever-jpeg-optim...
http://www.smashingmagazine.com/2009/07/15/clever-png-optimization-techniques/ http://www.smashingmagazine.com/2009/07/15/clever-png-optimi...
- Natsu 16y agoJPEGs do bad things to your color space, though. I certainly welcome a replacement. For example, see: http://www.hackerfactor.com/blog/index.php?/archives/250-Showing-JPEGs-True-Color.html http://www.hackerfactor.com/blog/index.php?/archives/250-Sho... and http://www.hackerfactor.com/blog/index.php?/archives/355-How-I-Met-Your-Mother-Through-Photoshop.html http://www.hackerfactor.com/blog/index.php?/archives/355-How... It would be nice to see a more modern replacement, assuming the technology is better. That said, I haven't read enough about WebP yet to know if it actually fixes any of those problems with the JPEG format.
- astrange 16y agoThat's a rounding loss, not a change to "your color space". In any case, JPEG supports storing RGB instead of YUV 4:2:0 (or even YUV 4:4:4). WebP _doesn't_ support this, but it really doesn't matter. The point of image files is for you to look at the image, not at the pixel values.
- Natsu 16y agoFrom the article I cited: "In fact, of the 16 million colors in the 24-bit true-color pallet, JPEG can only store about 2.3 million colors. That's about 14% of the available color space." and "If JPEG stored images using RGB, then the Q tables would cause colors to diverge. For example, blue would have the most loss due to compression so images would appear more reddish and greenish. Instead, images are converted to a different color representation: luminance, chrominance red, and chrominance blue (YCrCb). Changing any one of these values alters the red, green, and blue components concurrently and prevents color divergence."
- astrange 16y agoThe article you cited is nonsense. Quantization which causes one of the color channels to get darker is called a "DC shift" and encoders try very hard not to introduce it.