How to improve WordPress JPEG image compression
While porting a static site to WordPress I noticed some of my images were a bit blurry. WordPress takes care of resizing JPEGs on upload. Most of the times that’s very handy. However, sometimes you need to bump up the quality a bit.
Put this in your theme’s function.php
(or in a plugin) to modify the default compression rate value:
add_filter('jpeg_quality', function($arg){ return 90; // Any value from 1 ~ 100 });
The default compression rate value is 82%. I don’t recommend using 100 unless you are dealing with high quality photography.
Lastly, this won’t affect you’re already generated thumbnails, so you’ll want to regenerate those.