用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1336|回复: 0
收起左侧

[HELP] 图像处理函数不能处理多张图像的问题

[复制链接]
发表于 2014-8-29 16:10:54 | 显示全部楼层 |阅读模式
要实现的功能就是读取整个文件夹内的图像 生成对应的略缩图。
使用图像处理类 发现只有第一次读取的图片生成成功了。

其他的图像都没有成功。

代码如下,请大虾们帮我看下。
PHP复制代码
 
   $dir         = "upload/xixi";
    $current_dir = opendir( $dir );
    while( ( $file = readdir( $current_dir ) ) !== false )
    {
      $sub = $file;
      if( $sub == '.' || $sub == '..' )
      {
        continue;
      }
      else
      {
        $sub = $dir . '/' . $file;
        echo $sub . "----";
        $config['image_library']  = 'gd2';
        $config['source_image']   = $sub;
        $config['create_thumb']   = TRUE;
        $config['maintain_ratio'] = TRUE;
 
        $image    = GetImageSize($config['source_image']);
        $image_w  = $image[0];
        $image_h  = $image[1];
        $config['width']  = 220;
        $config['height'] = $image_h * ( 220 / $image_w);
        $this->load->library('image_lib', $config);
        if ( ! $this->image_lib->resize() )
        {
          echo $this->image_lib->display_errors();
        }
        else
        {
          echo "success <br />";
        }
        $this->image_lib->clear();
      }
    }
 
 
复制代码


输出结果:
PHP复制代码
 
[color=#000]upload/xixi/48cbe841697b8dd7ca3e92ced686a86b.jpg----success
[color=#000]upload/xixi/787c78ff2ab61e3a4b1d50029fab37e6.jpg----
Your server does not support the GD function required to process this type of image.
upload/xixi/cb16aeb4853e6b7b8ba840f467da9345.jpg----
Your server does not support the GD function required to process this type of image.
Your server does not support the GD function required to process this type of image.
upload/xixi/48cbe841697b8dd7ca3e92ced686a86b_thumb.jpg----
Your server does not support the GD function required to process this type of image.
Your server does not support the GD function required to process this type of image.
Your server does not support the GD function required to process this type of image.

 
复制代码



这个只是我写的一个测试。没有考虑全部的逻辑情况。这是为什么呢?

本版积分规则