Hi has the following function
function renderBusinessCard($details){
$filename = Templates::model()->getTemplateFileName($details['BusinessCards']['dp_id']);
header("Content-type: image/jpeg");
$image = $_SERVER['DOCUMENT_ROOT'].'resources/templates/'.$filename;
list($width,$height) = getimagesize($image);
$create = imagecreatefromjpeg($image);
$template = 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 an image in an image tag, like the following
<img src="<?php renderBusinessCard($details); ?>"
but somehow it always displays the garbled code on the screen, not the result that I want. Is it even possible? And as without using a separate file, I want it to remain in a function or method.
source
share