Support » Fixing WordPress » WP 3.5.1 wp-image-editor: Scaling up images does not work

  • I am trying to scale a jpg to a larger size than original size. After clicking on “Scale”-button WP is saying “Image has been saved”, but there is no change at all, with the image.
    Scaling to a lower size works as expected.

    Actually a new image file like somename-e1361912486333.jpg is created, but it has exact the same size as the original file.

    phpinfo() says I have gd library installed. No imagick.

    I checked on another host with virgin wp 3.5.1 installation – same issue.
    Can anyone confirm this wrong behavior?
    Or even better: Has a quick work around for this?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Bump.
    No one here who can upload a jpg and try to scale up an image with the “Edit image” functionality of media library?


    I wonder if there is something wrong with my installation or just with wordpress.


    I set up a ticket at and it turns out to be more a feature than a bug.

    In case someone needs scaling up functionality, put this in functions.php:

    /* Scale up images functionality in "Edit image" ...
    * See
    * This is slightly changed function image_resize_dimensions()
    in wp-icludes/media.php */
    function my_image_resize_dimensions( $nonsense, $orig_w, $orig_h, $dest_w, $dest_h, $crop = false) {
        if ( $crop ) {
            // crop the largest possible portion of the original image that we can size to $dest_w x $dest_h
            $aspect_ratio = $orig_w / $orig_h;
            $new_w = min($dest_w, $orig_w);
            $new_h = min($dest_h, $orig_h);
            if ( !$new_w ) {
                $new_w = intval($new_h * $aspect_ratio);
            if ( !$new_h ) {
                $new_h = intval($new_w / $aspect_ratio);
            $size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
            $crop_w = round($new_w / $size_ratio);
            $crop_h = round($new_h / $size_ratio);
            $s_x = floor( ($orig_w - $crop_w) / 2 );
            $s_y = floor( ($orig_h - $crop_h) / 2 );
        } else {
            // don't crop, just resize using $dest_w x $dest_h as a maximum bounding box
            $crop_w = $orig_w;
            $crop_h = $orig_h;
            $s_x = 0;
            $s_y = 0;
            /* wp_constrain_dimensions() doesn't consider higher values for $dest :( */
            /* So just use that function only for scaling down ... */
            if ($orig_w >= $dest_w && $orig_h >= $dest_h ) {
                list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h );
            } else {
                $ratio = $dest_w / $orig_w;
                $w = intval( $orig_w  * $ratio );
                $h = intval( $orig_h * $ratio );
                list( $new_w, $new_h ) = array( $w, $h );
        // if the resulting image would be the same size or larger we don't want to resize it
        // Now WE need larger images ...
        //if ( $new_w >= $orig_w && $new_h >= $orig_h )
        if ( $new_w == $orig_w && $new_h == $orig_h )
            return false;
        // the return array matches the parameters to imagecopyresampled()
        // int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h
        return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
    add_filter( 'image_resize_dimensions', 'my_image_resize_dimensions', 1, 6 );


    I have exactly the same annoying issue. Please fix this asap!

    ullemehner Thank you very much. I pasted that code into my functions.php and worked like a charm. You rock!

    I read the ticket you posted and seems like they underestimate the need, or don’t really care since it doesn’t make sense to them.

    This thread alone displays the merit in such a feature. My themes featured images are added to the top of each post with a border that is 650px and drop shadows with slight curling effect like paper. I use Instagrate which automatically populates my instagram images as post, except the come in a 612px.

    Yes is degrades the quality marginally, but its the difference of working with my them or not.

    Now if I could just somehow automate the upscaling id be even happier!

    I tried your solution with the Regenerate Thumbnails but I wasn’t lucky. This may be a “feautre” on programming side but it is a bug on design side where template depends on fixed dimensions.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP 3.5.1 wp-image-editor: Scaling up images does not work’ is closed to new replies.