Make WordPress Core

Ticket #48842: 48842.diff

File 48842.diff, 1.5 KB (added by azaozz, 5 years ago)
  • src/wp-includes/class-wp-image-editor-imagick.php

     
    332332                try {
    333333                        /*
    334334                         * To be more efficient, resample large images to 5x the destination size before resizing
    335                          * whenever the output size is less that 1/3 of the original image size (1/3^2 ~= .111),
     335                         * whenever the resampled source size is less that 1/3 of the original image size,
    336336                         * unless we would be resampling to a scale smaller than 128x128.
    337337                         */
    338338                        if ( is_callable( array( $this->image, 'sampleImage' ) ) ) {
    339                                 $resize_ratio  = ( $dst_w / $this->size['width'] ) * ( $dst_h / $this->size['height'] );
    340339                                $sample_factor = 5;
    341340
    342                                 if ( $resize_ratio < .111 && ( $dst_w * $sample_factor > 128 && $dst_h * $sample_factor > 128 ) ) {
    343                                         $this->image->sampleImage( $dst_w * $sample_factor, $dst_h * $sample_factor );
     341                                // Resampled source size.
     342                                $resampled_w = $dst_w * $sample_factor;
     343                                $resampled_h = $dst_h * $sample_factor;
     344
     345                                // Resampled source width * height ratio.
     346                                $resize_ratio = ( $resampled_w / $this->size['width'] ) * ( $resampled_h / $this->size['height'] );
     347
     348                                // 1/3 ^ 2 ~= 0.111
     349                                if ( $resize_ratio < .111 && $resampled_w > 128 && $resampled_h > 128 ) {
     350                                        $this->image->sampleImage( $resampled_w, $resampled_h );
    344351                                }
    345352                        }
    346353