在 PHP 中动态生成图像有时不起作用
我有一个页面需要加载几个动态生成的图像。 90% 的时间一切正常,但有时某些图像未生成(我只是得到了丢失的图像图标)。由于大多数时候它都有效,并且丢失的图像并不总是相同,我认为这可能与服务器没有足够的资源有关。有什么方法可以防止这种情况发生(并确保生成图像)?
I have a page that needs to load several dynamically generated images. Everything works fine 90% of the time, but sometimes some of the images are not generated (I just get the missing image icon instead). Since most of the times it works, and the missing images are not always the same, I think that maybe it has something to do with the server not having enough resources. Are there any ways I can prevent this from happening (and make sure the images get generated)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会尝试提高 PHP 的内存限制和超时并重新启动您的 Web 服务器。特别是,请查看 memory_limit 和 max_execution_time。
另外,在该配置文件中,查看output_buffering,它控制发送之前可以在内存中构建多少输出。这有时会影响标题之前可以输出的数量。
我假设您已经查看了日志文件,但我建议围绕图像生成语句编写调试,以查看它们是否返回。
I would try upping the memory limits and timeouts of PHP and restart your web server. In particular, look at memory_limit and max_execution_time.
Also in that configuration file, look at output_buffering, which controls how much of the output can be built up in memory before sending. This can sometimes affect how much can be output before the headers.
I assume you've already looked at your log files, but I would recommend writing out debugging around the image generation statements to see if they're returning or not.