0

我使用 php 脚本上传图像,如果图像太大,我希望能够更改图像的大小,然后创建相同图像的拇指,现在我调整了图像的大小,但拇指不是为某种原因......也没有错误。这是脚本:

        if($image_data['image_width'] > 1024 || $image_data['image_height'] > 768)
      {


    $config_resize = array(
            'source_image' => $image_data['full_path'],
            'new_image' => "./uploads/",
            'overwrite' => true,
            'maintain_ratio' => true,
            'width' => 1024,
            'height' => 768
            );
     $this->load->library('image_lib', $config_resize);
     if(! $this->image_lib->resize())
       {
         echo $this->image_lib->display_errors();
       }


    $config_thumb = array(
        'source_image' => $config_resize['source_image'],
        'new_image' => "./uploads/thumbs/",
        'maintain_ratio' => true,
        'width' => 150,
        'height' => 100
        );
    $this->load->library('image_lib', $config_thumb);

    if(! $this->image_lib->resize())
       {
         echo $this->image_lib->display_errors();
       }


      }
4

1 回答 1

2
.....
.....  

    $config_thumb = array(
                'source_image' => $config_resize['source_image'],
                'new_image' => "./uploads/thumbs/",
                'maintain_ratio' => true,
                'width' => 150,
                'height' => 100
                );

$this->image_lib->initialize($config_thumb); // <--- !!!

并且不要两次加载库

于 2011-04-10T23:51:04.990 回答