﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
18532	resized image dimensions incorrectly floored instead of rounded	_ck_		"Image dimensions are incorrectly floored instead of rounded to a proper number. Some attempt at ""fixup"" is done later in some processes to move them by a pixel, but still the way it's initially calculated is wrong.

'''For example:

A typical photo has a 3:2 (3/2 = 1.5) ratio.

If it's resized to 600px width, WP will make the height 399px - this is wrong.'''

It happens because of ''function wp_constrain_dimensions'' in ''media.php'' (~line 304) which floors the float using intval, which is wrong. 


{{{
	$w = intval( $current_width  * $ratio );
	$h = intval( $current_height * $ratio );
}}}

'''I propose'''

{{{
	$w = round( $current_width  * $ratio );
	$h = round( $current_height * $ratio );
}}}

Earlier in the function, both $ratio and $current_width are already handled as numbers, so they have to be valid numbers, no need to use intval for that reason, it's just being used to floor, which is bad in this case.

Using round is not a performance issue because this function is not used in realtime output for templates but typically in admin area.

Optionally while you are at it, put a filter on wp_constrain_dimensions and pass the filter all the values passed to the function before the array is returned at the end.
"	defect (bug)	new	normal	Awaiting Review	Media	2.5	normal		has-patch	
