CodeIgniter 中的 image_lib 不工作...代码只是停止...没有错误,什么也没有
对于我的一生,我无法弄清楚为什么 CodeIgniter 中的 image_lib (图像处理库)不起作用。我让它在我的本地机器上运行得很好,所以我知道代码是正确的。但是,当我上传到生产服务器时,尝试从图像创建缩略图只会使代码停止运行。
更重要的是 image_lib 没有返回错误消息...页面只是在此时停止...这是我的代码片段,
$config = array(
'source_image' => '/data/servers/misc/www_thesite_com/files/originals/thepicture.jpg',
'new_image' => '/data/servers/misc/www_thesite_com/files/thumbs',
'maintain_ratio' => true,
'create_thumb' => true,
'width' => 150,
'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$ThumbnailName = 'thepicture_thumb.jpg';
我也尝试使用以下代码进行检查:
if (!$this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
但是,什么也没发生。一切都在 $this->image_lib->resize(); 处停止不会抛出任何错误。
另请注意...GD2 已成功安装。不使用 CodeIgniter 时,我能够顺利执行其他标准图像处理。
有什么想法吗?
For the life of me, I can't figure out why image_lib (the image manipulation library) in CodeIgniter isn't working. I have it working perfectly fine on my local machine, so I know the code is right. But when I upload to a production server, trying to create a thumbnail from an image just stops the code dead in its tracks.
The kicker is that image_lib isn't spitting back an error message... the page just stops at that point... Here's my code snippet
$config = array(
'source_image' => '/data/servers/misc/www_thesite_com/files/originals/thepicture.jpg',
'new_image' => '/data/servers/misc/www_thesite_com/files/thumbs',
'maintain_ratio' => true,
'create_thumb' => true,
'width' => 150,
'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->resize();
$ThumbnailName = 'thepicture_thumb.jpg';
I've tried checking using the following code too:
if (!$this->image_lib->resize()) {
echo $this->image_lib->display_errors();
}
But, nothing happens. Everything just stops at $this->image_lib->resize(); without throwing any error whatsoever.
One other note... GD2 is successfully installed. I'm able to perform other standard image manipulation without a hitch when not using CodeIgniter.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我遇到了同样的问题,我修复了这个问题,
之后
使用似乎在加载库时提供配置是不够的,您需要初始化
I had the same problem and I fixed this using
just after
It seems that giving the configuration when you load the library isn't enough and you need to initialize
如果函数调用后没有代码执行,我认为问题与服务器相关。如果本地版本有效而生产版本损坏,情况也是如此。
也许您的服务器内存已达到限制,或者您的图片文件夹没有写入权限。
If no code executes after your function call, I'd expect the problem to be server related. This is also true if the local version worked and the production version breaks.
Perhaps your server memory limit is being reached or your picture folder doesn't have write permissions.
关于包含后续调用的要求,
这可能是由于自动加载 image_lib 库。
Regarding the requirement to include the subsequent call to
This is probably due to autoloading the image_lib library.