Hi have the following function
function renderBusinessCard($details){
//Getting the template for the business card
$filename = Templates::model()->getTemplateFileName($details['BusinessCards']['dp_id']);
header("Content-type: image/jpeg");
$image = $_SERVER['DOCUMENT_ROOT'].'resources/templates/'.$filename;
// header("Content-Type: image/jpeg");
//Getting the width and height of the image
list($width,$height) = getimagesize($image);
//echo $width;die;
//Creating a copy of a loaded image
$create = imagecreatefromjpeg($image);
//Creating a blank template to work from
$t开发者_如何学Cemplate = imagecreatetruecolor($width,$height);
imagecopyresized($template, $create, 0, 0, 0, 0, $width, $height, $width, $height);
imagejpeg($template, null, 100);
}
What I want to achieve is to display the image within an image tag like the following
<img src="<?php renderBusinessCard($details); ?>"
but somehow it's always rendering garbled code to the screen and not the result I want. Is this at all possible? And how without using a seperate file, I want this to remain within a function or method.
You need to render the image in a separate resource. There is no good way of adding the image data inside the HTML document. (Anybody thinking of recommending data:
URIs: It's a terrible idea.)
<img src="renderBusinessCard.php?param1=1¶m2=2">
It may be better to keep the $details array in session data if it's not too big. Then calling will call the script and associate the correct details data.
精彩评论