CodeIgniter 中的 image_lib 不工作...代码只是停止...没有错误,什么也没有

发布于 2024-10-27 04:29:02 字数 930 浏览 2 评论 0原文

对于我的一生,我无法弄清楚为什么 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 技术交流群。

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

发布评论

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

评论(3

遮云壑 2024-11-03 04:29:02

我遇到了同样的问题,我修复了这个问题,

$this->image_lib->initialize($config);

之后

$this->load->library('image_lib', $config);

使用似乎在加载库时提供配置是不够的,您需要初始化

I had the same problem and I fixed this using

$this->image_lib->initialize($config);

just after

$this->load->library('image_lib', $config);

It seems that giving the configuration when you load the library isn't enough and you need to initialize

路弥 2024-11-03 04:29:02

如果函数调用后没有代码执行,我认为问题与服务器相关。如果本地版本有效而​​生产版本损坏,情况也是如此。

也许您的服务器内存已达到限制,或者您的图片文件夹没有写入权限。

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.

心房的律动 2024-11-03 04:29:02

关于包含后续调用的要求,

$this->image_lib->initialize($config);

这可能是由于自动加载 image_lib 库。

Regarding the requirement to include the subsequent call to

$this->image_lib->initialize($config);

This is probably due to autoloading the image_lib library.

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