Item Previews ::
\n";
}
unset($i);
$sql = "SELECT * FROM `t_previews` TP WHERE `ID`='$id' ORDER BY `PreviewID`";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
$num_results = mysql_num_rows($sql_result);
if ($num_results>"0") {
?>
Add Preview
"690") {$width="690";}
if ($width > "520") {$width="520";}
$dest_width="$width"; // Destination Width /$tn_size_width
$dest_height_fixed="$height"; // Destination Height / $tn_size_height (Fixed)
$dest_height= ($src_height * $dest_width) / $src_width; // (Aspect Ratio Variable Height
if ($dest_height>$dest_height_fixed) {
$dest_height = $dest_height_fixed;
$dest_width = ($src_width * $dest_height) / $src_height;
}
$quality="80"; // JPEG Image Quality
$outputpath="$websitepath/$previewpath"; //path of output image ;-)
if ($type=="2") {
$src_img = imagecreatefromjpeg("$sourcepath");
} else if ($type=="3") {
$src_img = imagecreatefrompng("$sourcepath");
$quality="95";
}
$dst_img = imagecreatetruecolor($dest_width,$dest_height);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
imageinterlace($dst_img, 1);
$white = ImageColorAllocate($dst_img, 255, 255, 255);
//Make a couple of size corrections for the auto-border feature..
$dest_width = $dest_width-1;
$dest_height = $dest_height-1;
imagerectangle ($dst_img, 0, 0, $dest_width, $dest_height, $white);
$status = imagejpeg($dst_img, "$outputpath", $quality);
imagedestroy($src_img);
imagedestroy($dst_img);
if ($status=="1") {
//Lets attempt to add the record to the DB.
if (checkFormKey()) {
$sql = "INSERT INTO `t_previews` (`PreviewURI`,`ID`,`caption`,`preview`) VALUES ('/$previewpath','$id','$caption','$preview');";
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
if ($sql_result=="1") {
echo"Your File $filename ($filesize bytes) has been successfully uploaded and added to the database. Click here to refresh this page to show the added entry for editing.
";
}
}
}
} else {
echo"The image you uploaded has errors and could not be processed successfully. The image may be corrupt or not in the correct format. This tool only supports jpeg and png images. Please try your operation again.
\n";
}
}
?>