dolphin 发表于 2014-8-29 16:10:54

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

要实现的功能就是读取整个文件夹内的图像 生成对应的略缩图。
使用图像处理类 发现只有第一次读取的图片生成成功了。

其他的图像都没有成功。

代码如下,请大虾们帮我看下。
   $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;
      $image_h= $image;
      $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();
      }
    }



输出结果:

upload/xixi/48cbe841697b8dd7ca3e92ced686a86b.jpg----success
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.



这个只是我写的一个测试。没有考虑全部的逻辑情况。这是为什么呢?
页: [1]
查看完整版本: 图像处理函数不能处理多张图像的问题