[SOLVED] PHP generated image - output in the middle of HTML.
Posted: Wed Apr 13, 2005 6:17 am
Hi
I know PHP has many image processing functions and it looks like now I might look to use some of them.
The code below works and outputs the image, but how do I output the image into the middle of an HTML document?
I can output the image on a page on it's own...
The above code resizes $jpgFile to $width in size.
I've tried adding HTML code above and below the PHP and removing the content-type header, but obviously the image just comes through in a text stream.
How do you get it to output the image in the middle of HTML and text?
Obviously I need to do some kind of
But what do I set src as?
Thanks
Ben
I know PHP has many image processing functions and it looks like now I might look to use some of them.
The code below works and outputs the image, but how do I output the image into the middle of an HTML document?
I can output the image on a page on it's own...
Code: Select all
<?
$jpgFile = "http://www.domain.com/image.jpg";
$width = 100;
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($jpgFile);
$height = (int) (($width / $width_orig) * $height_orig);
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($jpgFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
header('Content-type: image/jpeg');
// Output
imagejpeg($image_p, "", 100);
?>I've tried adding HTML code above and below the PHP and removing the content-type header, but obviously the image just comes through in a text stream.
How do you get it to output the image in the middle of HTML and text?
Obviously I need to do some kind of
Code: Select all
echo("<img src=\"\">");Thanks
Ben