One more GD ? -- filename
| From: | Craig Hoffman | Date: | Wed, 06 Apr 2005 13:23:40 +0000 |
| Subject: | One more GD ? -- filename | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-39132@lists.php.net to get a copy of this message | ||
Thanks everyone for answering my other post. However, I'm still having trouble passing the image name from the GD script to the image tag. I'm including the GD script below. Any help would be great. Thanks - Craig
//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'>");