【问题标题】:show created image in codeigniter在 codeigniter 中显示创建的图像
【发布时间】:2012-04-23 14:59:51
【问题描述】:

我必须使用 php (codeigniter) 创建一个图像并且需要在浏览器中显示它。我有一个像下面这样的课程

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

// class Welcome extends CI_Controller {


    class Get_captcha extends CI_Controller {

 function __construct()
{
    parent::__construct();
    $this->load->library('session');
    $this->load->library('form_validation');
    $this->load->helper(array('form', 'url'));

}

function index()
{

// header('Content-Type: image/png');
Header("Content-type: image/png");
// Create the image
$im = imagecreatetruecolor(400, 30);

// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

// The text to draw
$text = 'Testing...';
// Replace path by your own font path
$font = 'verdana.ttf';

// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);


}



    }

当我打电话给http://localhost/tvc/index.php/get_captcha 时,它显示错误..

请任何人帮助我?

谢谢

【问题讨论】:

标签: php codeigniter image-processing


【解决方案1】:

最有可能的错误与未找到verdana.ttf有关...

【讨论】:

    猜你喜欢
    • 2015-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-28
    • 2016-02-05
    • 1970-01-01
    • 2011-05-28
    相关资源
    最近更新 更多