resize image problem
Posted: Sat Aug 28, 2010 11:25 am
Hello friends,
please am having problem with my image resize code the code is as below;
but the picture is not resized, and if i use
no picture will be uploaded to my upload folder.
please what can i do or which other lesser stress way can i resize my picture.
please am having problem with my image resize code the code is as below;
Code: Select all
$originalImage = $_FILES["file"]["name"];
$toWidth = 300;
$toHeight = 300;
function resizeImage($originalImage,$toWidth,$toHeight){
// Get the original geometry and calculate scales
list($width, $height) = getimagesize($originalImage);
$xscale=$width/$toWidth;
$yscale=$height/$toHeight;
// Recalculate new size with default ratio
if ($yscale>$xscale){
$new_width = round($width * (1/$yscale));
$new_height = round($height * (1/$yscale));
}
else {
$new_width = round($width * (1/$xscale));
$new_height = round($height * (1/$xscale));
}
// Resize the original image
$imageResized = imagecreatetruecolor($new_width, $new_height);
$imageTmp = imagecreatefromjpeg ($originalImage);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
return $imageResized;
}
move_uploaded_file($_FILES["file"]["tmp_name"],
"../upload/" . $imageResized);
$path2= "../upload/" . $imageResized;
Code: Select all
$image = resizeImage()
move_uploaded_file($_FILES["file"]["tmp_name"],
"../upload/" . $image);
$path2= "../upload/" . $image;
please what can i do or which other lesser stress way can i resize my picture.