[wp-trac] [WordPress Trac] #48842: Fix calculation error when resampling images before resizing in class-wp-image-editor-imagick.php

WordPress Trac noreply at wordpress.org
Sat Nov 30 18:34:35 UTC 2019


#48842: Fix calculation error when resampling images before resizing in class-wp-
image-editor-imagick.php
--------------------------+--------------------
 Reporter:  azaozz        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  5.3.1
Component:  Media         |    Version:  4.5
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+--------------------
 Seems there is a calculation error when resampling large images before
 resizing them to a much smaller sub-size. Looking at #33642 and [36700],
 the idea is to efficiently reduce the size of the original image before
 resizing by using ImageMagick's `sampleImage()`.

 However in some cases the resampled image may be larger than the original.
 Caused by doing the resampling when the destination image is about 1/3 of
 the size of the original, and using a (hard-coded) `$sample_factor = 5`,
 see https://core.trac.wordpress.org/browser/tags/5.3/src/wp-includes
 /class-wp-image-editor-imagick.php#L333.

 Example: for an original image of 1000x500 and destination image of
 300x150, the resampled source image will be 1500x750 (the `$resize_ratio`
 in this case is `0.09`).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48842>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list