gpt4 book ai didi

php - 警告 : imagettftext() [function. imagettftext] : Could not find/open font in/home/a2424901/public_html/index. php 第 35 行

转载 作者:IT王子 更新时间:2023-10-29 00:20:41 25 4
gpt4 key购买 nike

<?php
session_start();
require_once 'facebook.php';
$app_id = "418907881455014";
$app_secret = "36389d2c4caaf6de86982cb87686a494";
$redirect_uri = 'http://gooogle12.comuf.com';
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
$user = $facebook->getUser();
$user_profile = $facebook->api('/me');

$coded = $_REQUEST['code'];

$access_token = $facebook->getAccessToken();
$name = "".$user_profile['name']."";
$fbid = "".$user_profile['id']."";

function RandomLine($filename) {
$lines = file($filename) ;
return $lines[array_rand($lines)] ;
}
$reason = RandomLine("reason.txt");

$canvas = imagecreatefromjpeg ("bg.jpg"); // background image file
$black = imagecolorallocate( $canvas, 0, 0, 0 ); // The second colour - to be used for the text
$font = "Arial.ttf"; // Path to the font you are going to use
$fontsize = 20; // font size

$birthday = "".$user_profile['birthday']."";
$death = "- ".date('d/m/Y', strtotime( '+'.rand(0, 10000).' days'))."";

imagettftext( $canvas, 22, -1, 110, 120, $black, $font, $name ); // name
imagettftext( $canvas, 22, -1, 110, 170, $black, $font, $birthday ); // birthday
imagettftext( $canvas, 22, -1, 255, 172, $black, $font, $death ); // death
imagettftext( $canvas, 20, -1, 110, 220, $black, $font, $reason ); // reason


$facebook->setFileUploadSupport(true);

//Create an album
$album_details = array(
'message'=> 'How will you die?',
'name'=> 'How will you die?'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);

//Get album ID of the album you've just created
$album_uid = $create_album['id'];

//Upload a photo to album of ID...

$file='img/'.$fbid.'.jpg'; //Example image file

$photo_details = array( 'message'=> 'Find...51', 'image' => '@'.realpath($file));
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);


enter code here



ImageDestroy( $canvas );

header("Location: http://facebook.com".$fbid."&photoid=".$upphoto."")
?>

我正在使用此 php 代码制作一个 facebook 应用程序。我将字体 Arial.ttf 上传到我网站的根目录。但我仍然显示错误 - Warning: imagettftext() [function.imagettftext]: Could not find/open font in/home/a2424901/public_html/index.php on line 35。我尝试改变案例,但我没有为我工作。我在这段代码中哪里出错了?

最佳答案

From the docs

Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.

这似乎暗示字体文件应该是绝对路径,如果不是,函数将在其末尾附加另一个 .ttf

指定字体文件的完整路径。

$font = "/home/a2424901/public_html/Arial.ttf";

或者省略 .ttf 并使用 GDFONTPATHThe documentation建议如下:

In many cases where a font resides in the same directory as the script using it the following trick will alleviate any include problems.

putenv('GDFONTPATH=' . realpath('.'));
$font = "Arial";

关于php - 警告 : imagettftext() [function. imagettftext] : Could not find/open font in/home/a2424901/public_html/index. php 第 35 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10366679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com