0

以下のコードを使用して、joomla 1.5 で画像を作成しています

            $session=JFactory::getSession();
    $randomnr = rand(1000, 9999);
    $session->set('randomr2',md5($randomnr));
    $im = imagecreatetruecolor(100, 38);

$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 150, 150, 150);
$black = imagecolorallocate($im, 0, 0, 0);

imagefilledrectangle($im, 0, 0, 200, 35, $black);

//path to font - this is just an example you can use any font you like:

$font = dirName(__FILE__).'/font/karate/Karate.ttf';

imagettftext($im, 20, 4, 22, 30, $grey, $font, $randomnr);

imagettftext($im, 20, 4, 15, 32, $white, $font, $randomnr);

//prevent caching on client side:
header("Expires: Wed, 1 Jan 1997 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header ("Content-type: image/gif");
imagegif($im);
imagedestroy($im);

しかし、joomla 1.5で実行すると奇妙な文字が返されます.Joomla 1.5でテキストから画像を作成する他の方法はありますか.

または、artform joomla 1.5 コンポーネントのキャプチャを作成するためのプラグインを探しています。

4

1 に答える 1

0

私は自分で問題を解決しMIME ENCODINGて画像を追加しましたが、

2行追加するだけです

$document =& JFactory::getDocument();
$document->setMimeEncoding('image/png');

そしてあなたはあなたの道を見つけるでしょう。

于 2012-12-13T05:27:00.353 に答える