Hello, I have a php script which detects if an image is vericle or horizontal. Then it resizes it to my certian specifications. An issue is I want the script to resize the image and then create a thumbnail image as well. The script works when resizing an image but I cant make it create the thumb nail. This is the script.
<?php
include('SimpleImage.php');
//connect to database
$hostname = "localhost";
$username = "root";
$password = "";
$database = "";
$con = mysql_connect("$hostname","$username","$password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$database", $con);
$id = (md5(time()));
$thumb = (md5(time()));
if (isset($_POST['caption'])){
$caption = $_POST['caption'];
}
else{$caption = "";}
if (isset($_POST['column'])){
$column = $_POST['column'];
}
else{header('location:imageuploader.php');}
if (isset($_POST['slide'])){
$slide = $_POST['slide'];
}
else{header('location:imageuploader.php');}
list($width, $height, $type, $attr) = getimagesize($_FILES['uploaded_image']['tmp_name']);
if ($width > $height){
$stance = "h";
$image = new SimpleImage();
$image->load($_FILES['uploaded_image']['tmp_name']);
$image->resizeToWidth(440);
$image->save('uploaded_images/'.$id.'.png');
}
else{
$stance = "v";
$image = new SimpleImage();
$image->load($_FILES['uploaded_image']['tmp_name']);
$image->resizeToHeight(507);
$image->save('uploaded_images/'.$id.'.png');
}
//make thumb
$image = new SimpleImage();
$image->load($_FILES['uploaded_image']['tmp_name']);
$image->resizeToWidth(150);
$image->save('uploaded_images/'.$thumb.'.png');
$query = "INSERT INTO images
VALUES(
NULL,
'$id',
'$caption',
'$stance',
'$column',
'$slide',
'$thumb') ";
mysql_query($query);
echo mysql_error();
?>
With this script it only makes the thumbnail but if I remove the thumnail code it will create the larger image. I want it to create both.