phar打包后没办法显示验证码

a178251115

ErrorException: imagettfbbox(): Could not find/open font in
phar:///www/wwwroot/game.com/build/webman.phar/vendor/gregwar/captcha/src/Gregwar/Captcha/CaptchaBuilder.php:345
Stack trace:
没办法显示验证码,直接报错,用的是官方推荐的验证码

1730 3 0
3个回答

北月

字体路径的问题,imagettfbbox只支持传入字体文件路径的字符串或者URL,不支持流,没办法读取phar文件内部的字体文件,除非你自己传入外部字体文件的地址,不然确实没法整。

  • a178251115 2022-06-30

    暂时不知道怎么弄,只有不打包了

  • wanghaiyang 2022-09-22

    webman\vendor\gregwar\captcha\src\Gregwar\Captcha/Font/captcha5.ttf

  • wanghaiyang 2022-09-22

    注意中文目录的问题

  • wanghaiyang 2022-09-22

    还有一个浮点转整形的问题 \imagettftext($image, $size, $angle, intval($x), intval($y) + $offset, $col, $font, $symbol);

  • wanghaiyang 2022-09-22

    webman\vendor\gregwar\Captcha\src\Gregwar\Captcha\CaptchaBuilder.php line:365 我真心不知道你们咋会没问题,反正验证码我刷一会就会出现隐式转换的问题。

wanghaiyang

ErrorException: imagettfbbox(): Could not find/open
这个需要注意中文路径的问题

还有一个浮点转整形的问题
修改webman\vendor\gregwar\Captcha\src\Gregwar\Captcha\CaptchaBuilder.php line:365

\imagettftext($image, $size, $angle, intval($x), intval($y) + $offset, $col, $font, $symbol);

  • kspade 2023-02-10

    可有解决办法,我试了的确打包后验证码没法显示 imagettfbbox 调用未定义

  • walkor 2023-02-10

    PHP Fatal error: Call to undefined function imagettfbbox() 是gd扩展没开freetype,环境问题网上找下文章解决

walkor

webman/captcha,已经解决了phar打包后imagettfbbox(): Could not find/open font 问题。

  • 幸福的小猪 2023-02-23

    大佬,我今天才引用的验证码,还是出现了这个问题,请问下怎么解决呢?

年代过于久远,无法发表回答
🔝