|
|
|
|
@ -2270,15 +2270,20 @@ class UserManager |
|
|
|
|
} |
|
|
|
|
$temp = new image($file); |
|
|
|
|
$picture_infos = api_getimagesize($file); |
|
|
|
|
if ($picture_infos[0] > $max_size_for_picture) { |
|
|
|
|
$thumbwidth = $max_size_for_picture; |
|
|
|
|
if (empty($thumbwidth) or $thumbwidth == 0) { |
|
|
|
|
$thumbwidth = $max_size_for_picture; |
|
|
|
|
} |
|
|
|
|
$new_height = round(($thumbwidth / $picture_infos[0]) * $picture_infos[1]); |
|
|
|
|
if ($new_height > $max_size_for_picture) |
|
|
|
|
$new_height = $thumbwidth; |
|
|
|
|
$temp->resize($thumbwidth, $new_height, 0); |
|
|
|
|
list($width, $height) = api_getimagesize($file); |
|
|
|
|
if ($width >= $height) { |
|
|
|
|
if ($width >= $max_size_for_picture) { |
|
|
|
|
// scale height |
|
|
|
|
$new_height = round($height * ($max_size_for_picture / $width)); |
|
|
|
|
$temp->resize($max_size_for_picture, $new_height, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { // height > $width |
|
|
|
|
if ($height >= $max_size_for_picture) { |
|
|
|
|
// scale width |
|
|
|
|
$new_width = round($width * ($max_size_for_picture / $height)); |
|
|
|
|
$temp->resize($new_width, $max_size_for_picture, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return $temp; |
|
|
|
|
} |
|
|
|
|
|