Codeigniter图像调整大小无法正常工作

问题描述:

我想调整上传的图像大小为400 x 350的比例。我使用下面的代码为此。Codeigniter图像调整大小无法正常工作

$config = array(
     'image_library' => 'gd2', 
     'source_image'  => $img_data['full_path'], 
     'new_image'   => $this->upload_path. '/thumbs', 
     'maintain_ration' => FALSE, 
     'width'    => 350, 
     'height'   => 400 
    ); 

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

笨给我的形象的400×340

+0

任务所需的类? GD/GD2,NetPBM或ImageMagick – SomeShinyObject 2013-04-05 06:16:02

+0

你可以保留这两个选项$ config ['create_thumb'] = TRUE; $ config ['maintain_ratio'] = TRUE;由于启用了maintain_ratio选项,拇指将尽可能接近目标宽度和高度,同时保留原始高宽比。 – 2013-04-05 06:17:41

+0

谢谢Venkat。我像你说的那样尝试,但它仍然是400x340。 – wailynnoo 2013-04-05 06:28:47

的比例看,如果这能帮助。 这里是你已经安装的依赖关系的链接来完成你寻找

http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/