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) {
|
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
|
// read original image
|
||||||
$origImg = imagecreatefromjpeg($imageFile);
|
$origImg = imagecreatefromjpeg($imageFile);
|
||||||
$width = imagesx($origImg);
|
$width = imagesx($origImg);
|
||||||
$height = imagesy($origImg);
|
$height = imagesy($origImg);
|
||||||
// Create thumbnail in memory
|
// Create thumbnail in memory
|
||||||
$newHeight = 150;
|
$newHeight = 300;
|
||||||
$newWidth = ($width/$height) * $newHeight;
|
$newWidth = ($width/$height) * $newHeight;
|
||||||
$newImg = imagecreatetruecolor($newWidth, $newHeight);
|
/* Do not scale images which are already small enough */
|
||||||
// resize
|
if($newWidth < $width || $newHeight < $height) {
|
||||||
imagecopyresized($newImg, $origImg, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
$newImg = imagecreatetruecolor($newWidth, $newHeight);
|
||||||
// save to file
|
// resize
|
||||||
imagejpeg($newImg, $imageFile);
|
imagecopyresized($newImg, $origImg, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
|
||||||
// Clean up
|
// save to file
|
||||||
|
imagejpeg($newImg, $imageFile);
|
||||||
|
// Clean up
|
||||||
|
imagedestroy($newImg);
|
||||||
|
}
|
||||||
imagedestroy($origImg);
|
imagedestroy($origImg);
|
||||||
imagedestroy($newImg);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Location:../out/out.UsrMgr.php?userid=".$userid);
|
header("Location:../out/out.UsrMgr.php?userid=".$userid);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user