300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > php图像无法显示 php – 无法显示图像 因为它包含错误[图像生成器]

php图像无法显示 php – 无法显示图像 因为它包含错误[图像生成器]

时间:2021-12-22 04:12:45

相关推荐

php图像无法显示 php – 无法显示图像 因为它包含错误[图像生成器]

有图像生成器的一些问题.也许你会发现问题是什么?我得到:“图像无法显示,因为它包含错误”,我正在下载图像文件,但没有错误.

if(isset($_GET['id']) && $_GET['id']){

// require('../libs/global.inc.php');

$id = $_GET['id'];

$imagePath = "gov_220.jpg";//$track->getImg($id);

$framePath = "otgFrame.png";

$fontsize = 14;

$font = 'times.ttf';

$artistName = "bla bla";//$view->CutTheName("by ".$track->getArtist($id), 16);

//$artistName = iconv(mb_detect_encoding($artistName, mb_detect_order(), true), "UTF-8", $artistName);

$trackName = "la la";//$view->CutTheName($track->getName($id),16);

$photo = imagecreatefromjpeg($imagePath);

$w = imagesx($photo);

$h = imagesy($photo);

$new_image = imagecreatetruecolor(200, 200);

imagecopyresampled($new_image, $photo, 0, 0, 0, 0, 200, 200, $w, $h);

imagealphablending($new_image,true);

$frame = imagecreatefrompng($framePath);

imagecopy($new_image,$frame,0,0,0,0,200,200);

$fontcolor = imagecolorallocate($new_image, 255, 255, 255);

imagettftext($new_image, $fontsize, 0,2,177,$fontcolor, $font, $trackName );

$fontcolor = imagecolorallocate($new_image, 246, 228, 6);

imagettftext($new_image, $fontsize, 0,2,196,$fontcolor, $font, $artistName );

header('Content-type: image/png');

imagepng($new_image);

imagedestroy ($new_image);

}

?>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。