嗨它保存到磁盤具有以下功能要呈現的圖像,而無需使用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