Hi All, i have made this script already using imagemagic, but have just relised the server runs gd librarys, i know this script works in image magic (i have used it elsewhere) was wondering if somone could help me convert it to use gd please.
//Image Magick
$rndnum = rand(10,999999);
exec("C:\\imagemagick\\convert.exe -resize 800 ".$new_file." ".$path.$rndnum.$id."minus_01".".jpg");
exec("C:\\imagemagick\\convert.exe -resize 420 ".$new_file." ".$path.$rndnum.$id."minus_02".".jpg");
exec("C:\\imagemagick\\convert.exe -resize 105 ".$new_file." ".$path.$rndnum.$id."minus_03".".jpg");
exec("C:\\imagemagick\\convert.exe -resize 72 ".$new_file." ".$path.$rndnum.$id."minus_04".".jpg");
$dbsave = $rndnum.$id;
//print "<br>Thumbnail: ".$path."thumb".$rndnum.".jpg";
//deletes original image
unlink($new_file);
thats the image magic resize bit.
if you need the entire script here it is.
<?
//header('Refresh: 2; URL="register_test.php');
$path = "C:/path to image upload folder/";
//define("C_FILEPATH", "C:/path to image upload folder/");
$max_size = 1048576;
$id = $_GET['id'];
//chmod($path, 0777);
if (!isset($HTTP_POST_FILES['userfile'])) die ("No image selected.");
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { die("The file is too big<br>\n"); }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { die("The file already exists<br>\n");}
$tmp_file = $HTTP_POST_FILES['userfile']['tmp_name'];
$new_file = $path.$HTTP_POST_FILES['userfile']['name'];
$res = copy($tmp_file,$new_file);
if (!isset($res)) { die("Upload Failed!<br>"); }
echo "Upload Sucessful<br>Redirecting back to Your Details.<br>\n";
echo "File Name: ".$path.$HTTP_POST_FILES['userfile']['name']."<br>\n";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";
//Image Magick
$rndnum = rand(10,999999);
exec("C:\\imagemagick\\convert.exe -resize 800 ".$new_file." ".$path.$rndnum.$id."minus_01".".jpg");
exec("C:\\imagemagick\\convert.exe -resize 420 ".$new_file." ".$path.$rndnum.$id."minus_02".".jpg");
exec("C:\\imagemagick\\convert.exe -resize 105 ".$new_file." ".$path.$rndnum.$id."minus_03".".jpg");
exec("C:\\imagemagick\\convert.exe -resize 72 ".$new_file." ".$path.$rndnum.$id."minus_04".".jpg");
$dbsave = $rndnum.$id;
//print "<br>Thumbnail: ".$path."thumb".$rndnum.".jpg";
//deletes original image
unlink($new_file);
//insert images into database
$connection = mysql_connect("server","usernmae","password") or die('Could not connect to the database server');
$db = mysql_select_db("database", $connection) or die ("Unable to select database.");
$sql = "INSERT into images (listing_id,url) values('$id', '$dbsave')";
$sql_result = mysql_query($sql,$connection) or die ("Could not connect to database test");
} else { echo "Wrong file type<br>\n"; exit; }
}
?>
<script language="JavaScript">
opener.location.reload();
self.close();
</script>
any help is greatly appreciated.
cheers aron.