I have a from that get image then it must resize the image and upload to special folder.
by this code, the image cropped to new size but i want to resize it. any one help me?
$thumpic=time().rand(1000,9999).'.jpg';
$path = "upload/sell-images/";
$img = $_FILES['file']['tmp_name'];
$dst = $path;
if (($img_info = getimagesize($img)) === FALSE)
die("Image not found or not an image");
$MAX_WIDTH=300;
$MAX_HEIGHT=300;
$width = $img_info[0];
$height = $img_info[1];
$scale = min($MAX_WIDTH/$width, $MAX_HEIGHT/$height);
$new_width = floor($scale*$width);
$new_height = floor($scale*$height);
switch ($img_info[2]) {
case IMAGETYPE_GIF : $src = imagecreatefromgif($img); break;
case IMAGETYPE_JPEG : $src = imagecreatefromjpeg($img); break;
case IMAGETYPE_PNG : $src = imagecreatefrompng($img); break;
default : die("Unknown filetype");
}
$tmp = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $new_width, $new_height, $new_width, $new_height);
imagejpeg($tmp, $dst.$thumpic);