私はphpを使用して画像を作成していますが、ほとんどコーディングしていますが、非常に重要なポイントで立ち往生しています。その画像で選択したフォントファミリが必要ですが、フォントファミリを選択した場合にのみ、デフォルトのフォントが実行されます。このロジックは正しく実行されていません。フォントファミリを選択しなかった場合、デフォルトのフォントが実行されて入力が表示されますが、フォントを選択すると実行され、既存の画像が上書きされますが、画面に入力が表示されません。
何が問題なのか教えてください。これがphpファイルの私のコードです:
<?php
include_once('includes/includes.inc.php');
if(isset($_GET['txt'])){
$txt = $_GET['txt'];
$_SESSION['txt'] = $txt;
}
if(!isset($_SESSION['rand'])){
$rand = mt_rand(100,1000);
$_SESSION['rand'] = $rand;
}
$im = @imagecreate(288, 288) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 230, 248, 248);
$text_color = imagecolorallocate($im, 85, 85, 85);
if(isset($_GET['Smile'])){
$query = mysql_query("SELECT * FROm tbl_fonts WHERE font_name = '".$_GET['Smile']."'");
$get = mysql_fetch_array($query);
$desfon = 'images/fonts/'.$get['font_name'].'.ttf';
//echo $desfon;
imagettftext($im, 55, 0, 155, 55, $text_color, $desfon, $_SESSION['txt']);
}
else{
imagestring($im, 55, 155, 55, $_SESSION['txt'], $text_color);
}
header("Content-Type: image/png");
$filename1 = $_SESSION['txt'].$_SESSION['rand'].'.png';
imagepng($im,$filename);
echo '<img src="'.$filename.'" alt="" />';
?>