RE: One more GD ? -- filename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

If I understand correctly, you're using
"include/function_gd.php?route_photo=$thumb" as image source which is the
script you pasted. If you use a script as image source, the script should
output the image data - not just store the image.

I'm not sure what you're trying to do but if you have an image object in php
(eg $thumb), you should output that image:

<?php
	$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);
	header("Content-type: image/jpeg");		// tell the browser
to expect a JPG
	imagejpeg($thumb, "", 100);			// send the image to
the browser (filename="" => output instead of save)
	exit();
?>

However, you cannot use that to show multiple images from 1 script.

Jos


-----Original Message-----
From: Craig Hoffman [mailto:choffman@xxxxxxxxxx]
Sent: 06 April 2005 15:24
To: php-db@xxxxxxxxxxxxx
Subject:  One more GD ? -- filename


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'>");

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux