If you’ve noticed that your thumbnails are not quite as sharp as they should it, it’s because WordPress’ default compression ratio for image generation is not at 100%.
I’ve generally found that clients prefer quality images vs. the extra resources needed to generate said images, so this code snippet should in handy for you. This code also addresses images being resized via the new WP_Image_Editor class that was just released with WordPress 3.5.
While the old filter only handled the compression quality of JPG images, if your instance utilizes ImageMagick, the new filter applies the compression ratio to other image types as well. The filter expects an integer based on the scale of 1-100. WordPress defaults to 90, so feel free to leave it as it is or change it to whatever you may need it to be!
It should also be noted that if you decide to extend the new WP_Image_Editor class, you can set the quality of images individually via the WP_Image_Editor::set_quality() method. The filter listed above trumps this method as it is set on a global scale, but it can be useful for individual instances of creating new image sizes if a global filter doesn’t fit the bill.