I'm using WP CLI wp media regenerate to resize my thumbnails.

I've noticed something a bit weird. The original image I upload is a JPEG with a resolution (DPI) of 72. The images that are generated have a resolution of 96.

Is this something WordPress core is doing?

Here's what I'm seeing via Tools > Site Health > Media Handling

WordPress Site Health Media Handling

Here are the image sizes defined via Settings > Media

  • Thumbnail: 150 x 150
  • Medium Size: 300 x 300
  • Large Size: 1200 x 668

And then via my functions, I have the following image sizes defined:

function mytheme_add_custom_image_sizes() {
    add_image_size('landscape-large-1x', 600, 334, true);
    add_image_size('landscape-large-2x', 1200, 668, true); // Largest image available
    add_image_size('landscape-medium-1x', 450, 251, true);
    add_image_size('landscape-medium-2x', 900, 502, true);
    add_image_size('landscape-small-1x', 384, 214, true);
    add_image_size('landscape-small-2x', 768, 428, true);
    add_image_size('landscape-smallest-1x', 324, 180, true);
    add_image_size('landscape-smallest-2x', 648, 360, true);
    add_image_size('square-1x', 96, 96, true); 
    add_image_size('square-2x', 192, 192, true);
add_action('after_setup_theme', 'mytheme_add_custom_image_sizes');

It's also worth mentioning, that I have the following image adjustments via functions.php:

 * Remove srcset width limitation
function mytheme_remove_max_srcset_image_width($max_width) {
    return false;
add_filter('max_srcset_image_width', 'mytheme_remove_max_srcset_image_width');

 * Remove default images sizes
function mytheme_remove_default_image_sizes($sizes) {
    unset($sizes['1536x1536']); // Introduced in WP 5.3
    unset($sizes['2048x2048']); // Introduced in WP 5.3
    return $sizes;
add_filter('intermediate_image_sizes_advanced', 'mytheme_remove_default_image_sizes');

 * Remove large "scaled" images
add_filter('big_image_size_threshold', '__return_false');
  • what size is your thumbnail set to in settings? It sounds like the upscaling is what was unexpected, would I be right?
    – Tom J Nowell
    Jul 21, 2021 at 9:19
  • 1
    Hey @TomJNowell, I've updated my question with the image size information.
    – Sam
    Jul 21, 2021 at 9:27
  • Are you sure the original image's DPI was 72 and not 96 (or perhaps the DPI was not explicitly set, hence the default which might be 96 in your case, was then used)? You could also check if there are any plugins or custom code which might be changing the active image editor class - see the wp_image_editors filter. And I said so because with GD (where the image editor class is WP_Image_Editor_GD), the default image DPI is 96.
    – Sally CJ
    Jul 24, 2021 at 18:37
  • ...so even if the original image DPI was 72, 300, etc., images created/manipulated using GD would always have a 96 DPI - i.e. the original DPI (except for 96) is not preserved by default.
    – Sally CJ
    Jul 24, 2021 at 18:39
  • Hey, @Sam, have you managed to sort this out already or is it still an ongoing mystery? Could you provide us with a link to the problematic image, so that we could try to fiddle with it?
    – vlood
    Aug 25, 2021 at 8:21


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.