2016-11-23 108 views
0

您好我编码的图像生成从文本到影像,之后造成的,当我想保存为图像它显示我 -*.php file, and not .png (image)- 代码:无法保存使用php创建的图像 - imagepng();

$name = $_POST['tekst']; 
$file ="imgs/tbybc1.png"; 
header('Content-Type: image/png'); 
$im = imagecreatefrompng($file); 
$white = imagecolorallocate($im, 255, 255, 255); 
$grey = imagecolorallocate($im, 128, 128, 128); 
$black = imagecolorallocate($im, 0, 0, 0); 
$text = $name; 
$font = 'fonts/Roboto-Thin.ttf'; 
imagettftext($im, 40, 0, 70, 215, $white, $font, $text); 
//imagettftext($im, 20, 0, 260, 255, $white, $font, $data); 
imagepng($im); 
imagedestroy($im); 

我能为它做的,我用Google搜索,但我没有找到任何东西。有没有解决方案来做到这一点?或者如果有任何图像生成器的方法告诉我:)谢谢:)

回答

0

您可以使用htaccess重写为此。

例如。

RewriteRule ^/captcha.png$ /gen.php [NC,L] 

然后就在您的网页源captcha.png:

<img src="/captcha.png" alt="" />