嗨它保存到磁盘具有以下功能要呈现的图像,而无需使用PHP GD库
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
$template = imagecreatetruecolor($width,$height);
imagecopyresized($template, $create, 0, 0, 0, 0, $width, $height, $width, $height);
imagejpeg($template, null, 100);
}
我想实现的是类似下面的
<img src="<?php renderBusinessCard($details); ?>"
图像标签内显示图像
但不知何故,它总是呈现乱码到屏幕上,而不是我想要的结果。这是可能吗?以及如何不使用一个单独的文件,我想这留在一个函数或方法。
+1,但我推荐使用'data:URIs';)j/k – 2011-03-08 22:48:46
Thx,那么我需要这样做,谢谢。我会做的是我宁愿在一个文件夹中创建图像,然后从那里渲染它,由于应用程序的结构“长篇故事” – Roland 2011-03-09 06:30:42