Avoid a rare case of black line in cropped thumbnails, props miqrogroove, fixes #7748

git-svn-id: http://svn.automattic.com/wordpress/trunk@12280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-11-26 06:58:21 +00:00
parent 5f74404560
commit 16ebe3bc82
1 changed files with 12 additions and 11 deletions

View File

@ -272,22 +272,23 @@ function image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop=false
$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 = ceil($new_w / $size_ratio);
$crop_h = ceil($new_h / $size_ratio);
$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 {
} 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;