2017-07-31 94 views
-4

我正在制作注册表单,供用户上传照片。但是,照片的尺寸在每一页上都不相同。例如:第一页的照片尺寸是250x212,第二页是740x349,第三页是82x82等。我制作了如下所述的div风格尺寸,看起来很丑。 enter image description here如何使用PHP和codeigniter3框架调整图像大小?

但是,我发现eventviva/php-image-resize库,但没有得到如何使用它,在哪里包括等。我也没有找到教程。有人能帮助我吗?

+0

[这是在谷歌第一击(https://github.com/eventviva/php-image-resize)了点。它有指示。你不了解他们吗? – Quentin

+0

我在谷歌搜索,发现这个链接,但不明白在哪里,以及如何将其包括到我的项目?并在哪里使用?在我看来,模型还是控制器? –

回答

0

尝试image_lib

$this->load->library('upload'); 
      $config['upload_path'] = './uploads'; 
      $config['allowed_types'] ='csv|xls|xlsx'; 
      $config['max_size'] = 1024; //in KB 
      $config['overwrite'] = TRUE; 
      $config['encrypt_name'] = TRUE; 
      $config['max_filename'] = 25; 
      $this->upload->initialize($config); 
     if (!$this->upload->do_upload('image_name')) { 
       //if file upload failed then catch the errors 
       $this->handle_error($this->upload->display_errors()); 
       $is_file_error = TRUE; 
      } else { 
       //store the file info 
       $image_data = $this->upload->data(); 
       $config['image_library'] = 'gd2'; 
       $config['source_image'] = $image_data['full_path']; //get original image 
       $config['maintain_ratio'] = TRUE; 
       $config['width'] = 150; 
       $config['height'] = 100; 
       $this->load->library('image_lib', $config); 
       if (!$this->image_lib->resize()) { 
        $this->handle_error($this->image_lib->display_errors()); 
       } 
      } 

参考:I am unable to resize my image in codeigniter

+0

我可以用它制作3种不同的尺寸吗? –

+0

我认为它是可能的 –