Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php imagegif()函数工作不正常_Php_Image_Heroku_Gd - Fatal编程技术网

Php imagegif()函数工作不正常

Php imagegif()函数工作不正常,php,image,heroku,gd,Php,Image,Heroku,Gd,大家好,我正在尝试在运行时在图像上写入字符串,为此,我使用了GD的imagestring,但没有得到所需的输出,而是它的给定遇到了他的错误: imagegif():无法打开“temp/textImage.gif”进行写入:第157行的…中没有此类文件或目录警告: 然而,同样的代码在imagefttext()函数中运行良好,但由于我的主机提供商heroku不支持freetype库,所以我不得不切换 $message = “Hello World”; //Image

大家好,我正在尝试在运行时在图像上写入字符串,为此,我使用了GD的
imagestring
,但没有得到所需的输出,而是它的给定遇到了他的错误:

imagegif():无法打开“temp/textImage.gif”进行写入:第157行的…中没有此类文件或目录警告:

然而,同样的代码在
imagefttext()
函数中运行良好,但由于我的主机提供商
heroku
不支持freetype库,所以我不得不切换

        $message = “Hello World”;
        //Image Processing:
        $imageUrl = "image.gif";
        $imageId = imagecreatefromgif($imageUrl);

        $angle = 0;
        $xCord = 4;
        $yCord = 40;
        $imageColor = imagecolorallocate($imageId, 0, 0, 0);
        $fontUrl = "GOTHIC.TTF";
        $imageText = "HELOOOO";
        $imageTextLnght = strlen($imageText);
        $fontSize = (500 / $imageTextLnght) + 5;
        $imageFont = 1;

//imagefttext($imageId, $fontSize, $angle, $xCord, $yCord, $imageColor, $fontUrl, $imageText);
        imagestring($imageId, 5, $xCord, $yCord, $imageText, $imageColor);
        //header('Content-Type: image/gif');

        //Saving Image With Text:
        $textImage = 'temp/textImage.gif';
        imagegif($imageId, $textImage);
        imagedestroy($imageId);
请帮助我:
谢谢

确保
temp
存在,或者使用
mkdir
创建它


通常错误
无法打开。。当试图创建文件时,没有这样的文件或目录
,意味着该目录不存在

正如我所说,同样的代码在
imagefttext
上运行得非常好,
'temp/textmimage.gif'
不是一个现有文件,而是保存添加的文本文件的文件名。请检查文件夹
temp
和路径。如果不手动创建具有相同目录php脚本的
temp
文件夹,并授予777权限