Image can not be displayed because it contains error in php gd

独自空忆成欢 提交于 2019-12-01 19:34:22

Save the image file that errors and open it in a text editor like notepad or equivalent and see if any PHP errors are inside it. An error is occurring and outputting text then which corrupts the file. Do that and you will find what the error is.

I think @cryptic is right you need to use the real path for font use something like

$font_path = basename(dirname(__FILE__)).'/arial.ttf'; 

and please make sure the font exists in the directory.

I seriously doubted your font path, please double check your font and file in same directory and if it is, then change path like this,

$font_path = './arial.ttf';

Edit (As per Discussion in chat)

you must need an ttf file to use imagettftext() function place the arial.ttf file in your folder where your file reside

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!