How shrink file size when WordPress resizes an image?

I’ve optimized an image that is 1280px x 800px in width/height and is 150kb in file size. I have used add_image_size to WordPress to make different thumbnail, small and large versions of the uploaded image. However, when WordPress sizes this image, it’s much bigger in file size despite being smaller! I get this:

/* I only specified widths because the images keep the same ratio */ 

IMAGE NAME      WIDTH       FILE SIZE
--------------  -------     ----------
my-small-size   480px       112kb
my-medium-size  768px       211kb
my-large-size   1280px      150kb (I uploaded this version)

I have installed imagick, but don’t know if WordPress is using it. Is there a way to improve the compression that WordPress uses?

Read More

EDIT: These are png images.

Related posts

Leave a Reply

2 comments

  1. The default quality when saving in WordPress is 90%.

    If you want to change this, stick the following code in your functions.php for your theme:

    function reduce_wp_image_quality( $quality ) {
      return 60; // default is 90% quality
    }
    add_filter('wp_editor_set_quality', 'reduce_wp_image_quality');
    add_filter('jpeg_quality', 'reduce_wp_image_quality');
    

    This should affect all thumbnails generated by WordPress.

    wp_editor_set_quality is located in:

    • wp-includes/class-wp-image-edito.php:228

    jpeg_quality is located in:

    • wp-includes/class-wp-image-edito.php:241
    • wp-admin/includes/image-edit.php:319