[wp-trac] [WordPress Trac] #18532: resized image dimensions incorrectly floored instead of rounded

WordPress Trac wp-trac at lists.automattic.com
Sun Sep 4 17:28:52 UTC 2011


#18532: resized image dimensions incorrectly floored instead of rounded
--------------------------+------------------------------
 Reporter:  _ck_          |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  2.5
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------

Comment (by _ck_):

 Oops, I made an oversight in the first post (ticket).

 The statement that compares the upper and lower bounds must also use round
 and not intval to test the result.  This is the complete change:

 {{{
         if ( round( $current_width * $larger_ratio ) > $max_width ||
 round( $current_height * $larger_ratio ) > $max_height )
                 // The larger ratio is too big. It would result in an
 overflow.
                 $ratio = $smaller_ratio;
         else
                 // The larger ratio fits, and is likely to be a more
 "snug" fit.
                 $ratio = $larger_ratio;

         $w = round( $current_width  * $ratio );
         $h = round( $current_height * $ratio );
 }}}

 This is tested working on a very basic level, for example 3/2 images
 become 600:400 now instead of 600:399

 However it has not been tested robustly.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18532#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list