Greetings all,
I am struggling with a script on my server that is using alot of memory. I have upped the max file size and the memory limit to what my hosts will allow me to use.
The code below is the main "feature" script of the whole thing. I am wondering if there is a way to optimize it at all. My clients NEED to upload photos, some over 2-3MB.
$image = $_FILES["new_image"]["name"];
$uploadedfile = $_FILES['new_image']['tmp_name'];
/* START DEALING WITH THE UPLOADED IMAGE */
if ($image) {
$filename = stripslashes($_FILES['new_image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
$uploadedfile = $_FILES['new_image']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height) = getimagesize($uploadedfile);
/* SET LARGE PHOTO SIZES */
$newwidth=600;
$newheight=450;
$tmp = imagecreatetruecolor($newwidth,$newheight);
/* SET THUMBNAIL SIZES */
$newwidth1=250;
$newheight1=188;
$tmp1 = imagecreatetruecolor($newwidth1,$newheight1);
/* COPY THE IMAGES */
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
/* RENAME THE PHOTOS */
$newimagename = $hname.'.'.$extension;
$newimagename1 = $hname.'.'.$extension;
/* STORE THE IMAGE AND THUMBNAIL */
$filename = "../../****/images/****/". $newimagename;
$filename1 = "../../****/images/****/thumbs/". $newimagename1;
imagejpeg($tmp,$filename,100); imagejpeg($tmp1,$filename1,100);
imagedestroy($src); imagedestroy($tmp); imagedestroy($tmp1);
}
I really would appreciate any help. I have asked this question on other sites but unfortunately have not had a response, I am now really under pressure to find an answer.
Many thanks for your time.