//GD script
<?php
include ("db.php");
$query = "SELECT route_photo FROM routes WHERE route_photo IS NOT NULL ORDER BY RAND() LIMIT 1";
$result = mysql_query($query, $db) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
//Photo varibale
$route_photo = $row["route_photo"];
//Start GD
//New Image resize
$new_width = 125;
$new_height = 225;
//Content Type
header("Content-type: image/jpeg");
//Start new image resize
list($width_orig, $height_orig) = getImageSize("../images/climbs/$route_photo");
if ($new_width && ($width_orig < $height_orig)) {
$new_width = ($new_height / $height_orig) * $width_orig;
} else {
$new_height = ($new_width / $width_orig) * $height_orig;
}
//resample the image
$thumb = ImageCreateTrueColor($new_width, $new_height);
$tmp_image = ImageCreateFromJPEG("../images/climbs/$route_photo");
ImageCopyResampled($thumb, $tmp_image, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig);
ImageJPEG($thumb, $route_photo, '100');
ImageDestroy($thumb);
}
?>
//Image Tag:
echo ("<img src='include/function_gd.php?route_photo=$thumb' align='center' id='image'>");
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php