【发布时间】:2014-01-26 14:09:03
【问题描述】:
我最喜欢的网站和第一次在这里写作。我已经使用 php 在图像上写了这在我的本地主机上工作正常,但它在互联网(000webhost)上不起作用我已经用谷歌搜索然后检查我的 gd 库是否打开,我还设置了所有权限,但图像仍然没有显示。
<?php
session_start();
// File and new size
$filename = 'images/solar-kid.jpg';
if(isset($_POST['sub']))
{
$txt=$_POST['txt'];
}
// Content type
header('Content-Type:image/jpeg');
// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = 350;
$newheight = 300;
// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
// Resize
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$white = imagecolorallocate($thumb, 255, 255, 255);
$grey = imagecolorallocate($thumb, 128, 128, 128);
$black = imagecolorallocate($thumb, 0, 0, 0);
imagefilledrectangle($thumb, 0, 0, 399, 29, $black);
imagefilledrectangle($thumb, 0, 270, 399, 299, $black);
$white = imagecolorallocate($thumb, 255, 255, 255);
$black = imagecolorallocate($thumb, 0, 0, 0);
$text = $txt;
$font = 'times.ttf';
imagettftext($thumb, 15, 0, 10, 20, $white, $font, $text);
// Output
imagejpeg($thumb);
?>
这是它在Click here网站上显示的结果
【问题讨论】: