is'nt working.. I got the script from the net and put it together with my upload script.. but it doesnt appear to be working. Could someone point out the errors?
P.S. my webhost has GD 1.3 v.. from the manual, I know that it works with GIF files (below v 1.6) but when I use imagecreategif, it says the command is'nt valid.
So if the system runs on GD 1.3, how can I resize both gif and jpg? I would like to have the script detect whetehr the width is bigger than 400, if so, the scale will be width/400.. and when resizing, I want both height and witdh to be divided by the scale..
here's my script:
if ($file_name) {
if (!ereg("/$", $path_to_file))
$path_to_file = $path_to_file."/";
$filearray = explode(".",$file_name);
$extension = end($filearray);
$time = date(y_M_d).'_';
$new_name = uniqid("$time");
$newname = $new_name.'.'.$extension;
$location = $path_to_file.$newname;
copy($file,$location);
$size = getimagesize($location);
if (($isize[0] > 250) || ($size[1] > 200)) {
/*== temp image file -- use "tempnam()" to generate the temp
file name. This is done so if multiple people access the
script at once they won't ruin each other's temp file ==*/
$tmpimg = tempnam("../carpicupload/privateseller/tmp", "MKUP");
/== RESIZE PROCESS
1. decompress jpeg image to pnm file (a raw image type)
2. scale pnm image
3. compress pnm file to jpeg image
==/
/*== Step 1: djpeg decompresses jpeg to pnm ==*/
system("djpeg $location >$tmpimg");
/*== Steps 2&3: scale image using pnmscale and then
pipe into cjpeg to output jpeg file ==*/
system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile");
/*== remove temp image ==*/
unlink($tmpimg);
}
unlink($file);
$content .= "Uploaded File 1: ".$location. " (".$size[1]. "h by " .$size[0]."w)\n";
}
any help will be really appreciated. Thank!