是什么导致 imagecreatetruecolor() 失败?

发布于 2024-08-02 04:40:49 字数 661 浏览 7 评论 0原文

我确信我的 gdlib 已启用,因为 imagecreafromjpeg() 函数位于我调用 imagecreatruecolor() 的部分之前,并且不会生成任何错误

然而,脚本在调用 imagecreatruecolor() 的部分中断(或者更确切地说失败,没有错误消息,只是返回 false)。
如何查找失败原因?

if ($filetype=='jpg' || $filetype=='jpeg')
    $src_img = imagecreatefromjpeg($name);      
if ($filetype=='png')
    $src_img = imagecreatefrompng($name);       
if($src_img===false){ return false;}

$orig_w = imageSX($src_img);
$orig_h = imageSY($src_img);
$new_w = ($orig_w > $new_w) ? $new_w : $orig_w;
$new_h = ($orig_h > $new_h) ? $new_h : $orig_h;
$dst_img = imagecreatetruecolor($new_w,$new_h);

i am sure that my gdlib is enabled since the imagecreafromjpeg() function precedes the part where i call the imagecreatruecolor() and there's no error generated from that

however the script breaks on the part (or rather fails with no error message and simply returns false) where imagecreatruecolor() is called..

how can i find the cause of the failure?

if ($filetype=='jpg' || $filetype=='jpeg')
    $src_img = imagecreatefromjpeg($name);      
if ($filetype=='png')
    $src_img = imagecreatefrompng($name);       
if($src_img===false){ return false;}

$orig_w = imageSX($src_img);
$orig_h = imageSY($src_img);
$new_w = ($orig_w > $new_w) ? $new_w : $orig_w;
$new_h = ($orig_h > $new_h) ? $new_h : $orig_h;
$dst_img = imagecreatetruecolor($new_w,$new_h);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

御守 2024-08-09 04:40:49

创建 phpinfo 文件来检查您的 GD 版本。 imagecreatetruecolor() 仅在 2.0.1 或更高版本中可用(他们推荐 2.0.28)。

也尝试“function_exists('imagecreatetruecolor')”。

Create a phpinfo-file to check your GD-version. imagecreatetruecolor() is only available in version 2.0.1 or later (they recommend 2.0.28).

Try the "function_exists('imagecreatetruecolor')" as well.

浴红衣 2024-08-09 04:40:49

有同样的问题。我所做的是将 error_report(E_ALL) 放在 imagecreatetruecolor 之前,发现它需要更多内存。刚刚将我的 php.ini 升级到 256mb,现在工作正常。

Had the same problem. What i did was put the error_report(E_ALL) before my imagecreatetruecolor and found out that it needs more memory. Just upgraded my php.ini to 256mb and its working fine now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文