mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
do not scale user image if too small, allow images up to 300px height
This commit is contained in:
parent
4cb589b0ed
commit
929c93fdb9
|
@ -485,30 +485,27 @@ else UI::exitError(getMLText("admin_tools"),getMLText("unknown_command"));
|
|||
|
||||
|
||||
function resizeImage($imageFile) {
|
||||
|
||||
// Not perfect. Creates a new image even if the old one is acceptable,
|
||||
// and the output quality is low. Now uses the function imagecreatetruecolor(),
|
||||
// though, so at least the pictures are in colour.
|
||||
|
||||
// read original image
|
||||
$origImg = imagecreatefromjpeg($imageFile);
|
||||
$width = imagesx($origImg);
|
||||
$height = imagesy($origImg);
|
||||
// Create thumbnail in memory
|
||||
$newHeight = 150;
|
||||
$newHeight = 300;
|
||||
$newWidth = ($width/$height) * $newHeight;
|
||||
/* Do not scale images which are already small enough */
|
||||
if($newWidth < $width || $newHeight < $height) {
|
||||
$newImg = imagecreatetruecolor($newWidth, $newHeight);
|
||||
// resize
|
||||
imagecopyresized($newImg, $origImg, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||
// save to file
|
||||
imagejpeg($newImg, $imageFile);
|
||||
// Clean up
|
||||
imagedestroy($origImg);
|
||||
imagedestroy($newImg);
|
||||
}
|
||||
imagedestroy($origImg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
header("Location:../out/out.UsrMgr.php?userid=".$userid);
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user